Valgrind肯定会丢失8个字节,但我释放了内存。
==11492== 8 bytes in 1 blocks are definitely lost in loss record 3 of 4
==11492== at 0x4029F6F: malloc (vg_replace_malloc.c:270)
==11492== by 0x8049778: list_add (list.c:169)
==11492== by 0x8049B9F: process_new_allocation_stats_and_state_PRIVATE (m61_allocation_core.c:54)
==11492== by 0x8049CAC: attempt_create_allocation (m61_allocation_core.c:86)
==11492== by 0x8048984: m61_malloc (m61.c:70)
==11492== by 0x80487C4: main (mytest.c:12)
list.c:
169 lnode *n = (lnode *) malloc(sizeof(lnode));
170 n->value = value;
171 syslog(LOG_NOTICE,"in list_add. added lnode=%p Adding active_allocation n->value=%p\n", n, value);
...
245 syslog(LOG_NOTICE,"Freeing (*tmp)=%p\n", (*tmp));
246 syslog(LOG_NOTICE,"(*nptr)->next=%p &(*nptr)->next=%p\n", (*nptr)->next, &(*nptr)->next);
247 *nptr = (*nptr)->next;
248 *nptr = (*nptr)->next;
249 free(*tmp); //Free this lnode
list.c日志的第一部分:
Sep 27 00:05:27 appliance m61[11492]: in list_add. added lnode=0x420abb8 Adding active_allocation n->value=0x42088b0
第二部分记录:
Sep 27 00:05:27 appliance m61[11492]: Freeing (*tmp)=0x420abb8