如下面的代码所示:
typedef struct list {
...
...
struct Data *data;
} List;
List* list = (List*)malloc(sizeof(List))
struct Data* data = (struct Data*) malloc(sizeof(struct Data));
.....// here fill the `data`
list->data = data;
....
struct Data* new_data = list->data;
free(list); /* my question is: will this `free` influence `new_data` */
Run Code Online (Sandbox Code Playgroud)
我有一个结构列表,其中有一个指向某些内容的指针,如果ist被释放,指针也会被释放new_data,是否受到影响?谢谢!