c - if a pointer is freed, how about the content it points to? will it be influenced or not? -
as in following code:
typedef struct list { ... ... struct data *data; } list; list* list = (list*)malloc(sizeof(list)) struct data* data = (struct data*) malloc(sizeof(struct data)); .....// here fill `data` list->data = data; .... struct data* new_data = list->data; free(list); /* question is: `free` influence `new_data` */ i have structure list, in there pointer, points content, if ist freed, pointer freed how new_data, influenced or not? thanks!
the contents of new_data not affected. still valid after "parent" data freed.
Comments
Post a Comment