typedef char *string;
struct node_t
{
struct node_t *prev;
string data;
struct node_t *next;
};
typedef struct node_t *node;
struct list_t{
struct node_t *head;
struct node_t *tail;
};
typedef struct list_t *list;
void list_destroy (list l){
node next = NULL;
if (l != NULL) {
node tmp = l->head;
while (tmp!=NULL) {
next = tmp->next;
free(tmp->data);
free(tmp);
tmp = next;
}
free(l);
}
};
I am trying to write function to free double linked list, when I am free char* type data, why it still have '\0' left? how can I free it completely?