Question: C language debugging - free memory typedef struct node{ int data; struct node* next; }node_t; typedef struct stack{ int count; // count keeps track of
C language debugging - free memory
typedef struct node{
int data;
struct node* next;
}node_t;
typedef struct stack{
int count; // count keeps track of how many items
// are in the stack.
unsigned int capacity; // Stores the maximum size of our stack
node_t* head; // head points to a node on the top of our stack.
}stack_t;
//Write a function to free stack - use valgrind to check
void free_stack(stack_t* s){
free(s); // By doing this we still have memory leakage, how can I free the data in node_t?
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
