output_s = (char**)malloc(sizeof(char*));
output_s[0] = (char*)malloc(sizeof(char));
output_s[0] = NULL;
So what I'm trying to create is a char array that would normally be a char array of char* strings, but for this specific input case I want to make an array that only contains a NULL entry, and for some reason when I create the entry I can free my array, but cannot free the entry that was set to null and 1 byte is leaked.
free(result[0]);
free(result);
That is later called to free the memory, with result being the returned output_s variable from above
==18402== HEAP SUMMARY:
==18402== in use at exit: 1 bytes in 1 blocks
==18402== total heap usage: 3 allocs, 2 frees, 1,033 bytes allocated
==18402==
==18402== 1 bytes in 1 blocks are definitely lost in loss record 1 of 1
==18402== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck- amd64-linux.so)
==18402== by 0x4007D1: camel_caser (camelCaser.c:33)
==18402== by 0x400CE4: test_camelCaser (camelCaser_tests.c:30)
==18402== by 0x400D47: main (camelCaser_main.c:13)
==18402==
==18402== LEAK SUMMARY:
==18402== definitely lost: 1 bytes in 1 blocks
==18402== indirectly lost: 0 bytes in 0 blocks
==18402== possibly lost: 0 bytes in 0 blocks
==18402== still reachable: 0 bytes in 0 blocks
==18402== suppressed: 0 bytes in 0 blocks
camelCaser.c:33 is the line that mallocs the
output_s[0] = (char*)malloc(sizeof(char));
output_sdefined?int a = 5; a = 14;"why isn'taequal to 5 anymore?"