【发布时间】:2013-10-27 19:04:54
【问题描述】:
在 C 语言中,我有类似的东西:
typedef struct bucket {
int value;
struct bucket *next;
} Bucket;
typedef struct table {
int size;
Bucket **buckets;
} Table;
现在我做Table *t = malloc(sizeof(Table));
还有t->buckets = calloc(10, sizeof(Bucket));
释放表 *t 是free(t);对吗?
现在,我如何才能释放存储桶链表和每个节点?
【问题讨论】:
-
它可以编译吗?
struct next *bucket不应该是结构bucket *bucket; -
抱歉应该是struct bucket *next
标签: c linked-list free nodes dynamic-memory-allocation