The following illustrates the information valgrind generates when we have not freed dynamically-allocated memory.
==2845066== 8 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==2845066== at 0x484482F: malloc (vg_replace_malloc.c:431) ==2845066== by 0x401269: create_photo (photo_album.c:16) ==2845066== by 0x401502: add_photo_to_album (photo_album.c:80) ==2845066== by 0x4011D4: main (public03.c:11) ==2845066== ==2845066== 12 bytes in 1 blocks are definitely lost in loss record 2 of 2 ==2845066== at 0x484482F: malloc (vg_replace_malloc.c:431) ==2845066== by 0x401269: create_photo (photo_album.c:16) ==2845066== by 0x401502: add_photo_to_album (photo_album.c:80) ==2845066== by 0x4011BE: main (public03.c:10)
The following illustrates the information valgrind generates when we tried to access uninitialized memory allocated in the heap.
==2846814== Use of uninitialised value of size 8 ==2846814== at 0x48D156B: _itoa_word (in /usr/lib64/libc.so.6) ==2846814== by 0x48EB11B: __vfprintf_internal (in /usr/lib64/libc.so.6) ==2846814== by 0x48D74DE: printf (in /usr/lib64/libc.so.6) ==2846814== by 0x401225: main (public03.c:17) ==2846814== Uninitialised value was created by a heap allocation ==2846814== at 0x484482F: malloc (vg_replace_malloc.c:431) ==2846814== by 0x4011A6: main (public03.c:9)
The following illustrates the information valgrind generates when we tried to access uninitialized memory allocated in the stack.
==2846814== Use of uninitialised value of size 8 ==2846814== at 0x48D156B: _itoa_word (in /usr/lib64/libc.so.6) ==2846814== by 0x48EB11B: __vfprintf_internal (in /usr/lib64/libc.so.6) ==2846814== by 0x48D74DE: printf (in /usr/lib64/libc.so.6) ==2846814== by 0x40120E: main (public03.c:16) ==2846814== Uninitialised value was created by a stack allocation ==2846814== at 0x401186: main (public03.c:6)