我释放了我创建的指针,但 Valgrind 仍然报告我丢失了字节,所以我不确定如何处理它。
有问题的代码是:
listNode* temp = (listNode*)malloc(sizeof(listNode));
node = list->head;
while (node != NULL)
{
temp = node->next;
free(node->entry);
free(node);
node = temp;
}
free(temp);
使用 valgrind 输出:
16 bytes in 1 blocks are definitely lost in loss record 13 of 21
==2137== at 0xB823: malloc (vg_replace_malloc.c:266)
==2137== by 0x100001B1E: freeList (main.c:110)
==2137== by 0x100001CB5: main (main.c:157)