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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!