I'm trying to bolster my understanding of C having never really delved into it properly and have taken to following the 'Learn C The Hard Way' tutorials online as a starting point. I'm a reasonably confident programmer but I thought starting right from the beginning would be the best way to ensure my full understanding of the concepts having come from mostly using higher level languages like Python and C#.
Exercise 6 on variable types gives the following sample to run (condensed to relevant lines only):
#include <stdio.h>
int main(int argc, char *argv[])
{
float power = 2.345f;
printf("You have %f levels of power.\n", power);
return 0;
}
While compiling and running this there's no issue, but the tutorial series encourages the use of Valgrind to help debugging. Upon running Valgrind, I notice the following:
HEAP SUMMARY:
in use at exit: 26,032 bytes in 187 blocks
total heap usage: 271 allocs, 84 frees, 32,264 bytes allocated
148 (80 direct, 68 indirect) bytes in 1 blocks are definitely lost in loss record 43 of 66
at 0x100007D81: malloc (vg_replace_malloc.c:303)
by 0x1001C78D6: __Balloc_D2A (in /usr/lib/system/libsystem_c.dylib)
by 0x1001C821F: __d2b_D2A (in /usr/lib/system/libsystem_c.dylib)
by 0x1001C4877: __dtoa (in /usr/lib/system/libsystem_c.dylib)
by 0x1001ED3E6: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
by 0x1002166C8: __v2printf (in /usr/lib/system/libsystem_c.dylib)
by 0x1001EC389: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
by 0x1001EA223: printf (in /usr/lib/system/libsystem_c.dylib)
by 0x100000F58: main (ex6.c:7)
LEAK SUMMARY:
definitely lost: 80 bytes in 1 blocks
indirectly lost: 68 bytes in 2 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 0 bytes in 0 blocks
suppressed: 25,884 bytes in 184 blocks
While it isn't noted as an error or a warning, I'm curious as to what this means? I'm familiar with memory leaks as being memory that is used and then not freed up and I get the feeling that this is something to do with the precision of the float but I'd like to truly understand what is going on here and what the significance of this leak is? Sadly the tutorials don't mention anything on it.