C language: Releasing memory of pointers to struct

后端 未结 4 1627
一整个雨季
一整个雨季 2021-01-20 06:28

Say I have declared a pointer to a struct and assign it with malloc() using this definition

typedef struct node {
    int info;
    struct node *next;
} NODE         


        
4条回答
  •  情话喂你
    2021-01-20 07:00

    You release neither node1 nor node2. You release the memory they point to.

    With that in mind, it should become clear why you should only call free once

提交回复
热议问题