==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
See in my project I use malloc like this:
malloc(sizeof(some_structure) * some_expression);
at one point some_expression gives value 0 so indirectly i am doing
malloc(0)
So when I am not going to malloc a single byte so I am not making free it but in that case valgrind shows memory leackage. Why?
Edit :
If I use like this:
char *a = malloc(0);
Then a is not NULL. So question is why not NULL? & Which address it stores?