embedded dynamic allocation problem

Hi all:
i dont know if it is suitable to refer to this self-made terms "embedded dynamic allocation".Consider the following case:
1
2
3
4
5
6
7
typedef struct tnode {
 char *data;
 struct tnode *next;
} node;
 node* tmp= (node *)malloc(sizeof(node));
 tmp->data = calloc(1000,sizeof(char));
 free(tmp);


then,will the memory referred by tmp->data be de-allocated ? I really doubt it? Anybody has any ideas on this ?

Thanks in advance!
It won't be released. It's garbage.
closed account (1yR4jE8b)
You need to free tmp->data first before you free tmp.
thank you, when i first see this,i was very worried.
Topic archived. No new replies allowed.