1
==20420==
==20420== HEAP SUMMARY:
==20420== in use at exit: 0 bytes in 1 blocks
==20420== total heap usage: 1 allocs, 0 frees, 0 bytes allocated
==20420==
==20420== Searching for pointers to 1 not-freed blocks
==20420== Checked 48,492 bytes
==20420==
==20420== 0 bytes in 1 blocks are still reachable in loss record 1 of 1
==20420== at 0x400677E: malloc (vg_replace_malloc.c:195)
==20420== by 0x80483D8: main (jig.c:10)
==20420==
==20420== LEAK SUMMARY:
==20420== definitely lost: 0 bytes in 0 blocks
==20420== indirectly lost: 0 bytes in 0 blocks
==20420== possibly lost: 0 bytes in 0 blocks
==20420== still reachable: 0 bytes in 1 blocks
==20420== suppressed: 0 bytes in 0 blocks
見我的項目,我用malloc這樣的:Valgrind的輸出瞭解
malloc(sizeof(some_structure) * some_expression);
在一個點some_expression給出值0,這樣間接地我做
malloc(0)
所以,當我不去malloc單個字節,所以我不釋放它,但在這種情況下valgrind顯示內存泄漏。爲什麼?
編輯:
如果我用這樣的:
char *a = malloc(0);
然後一個不爲空。所以問題是爲什麼不是NULL? &它存儲哪個地址?
的[零字節在Valgrind的丟失]可能重複(http://stackoverflow.com/questions/5498395/zero-bytes-中損失的Valgrind的) –