Search notes:

Valgrind

Simple example

prog.c

#include <stdlib.h>

int main() {

    char *mem_1 = malloc(100);
    char *mem_2 = malloc(200);

    free(mem_1); // Note: mem_1 is freed twice, but
    free(mem_1); // mem_2 is not freed at all.

}
Github repository about-Valgrind, path: /first/prog.c

Makefile

valgrind.out: prog
	valgrind --log-file=valgrind.out prog 

prog: prog.c
	gcc -g prog.c -o prog
Github repository about-Valgrind, path: /first/Makefile

See also

Memory alloction with libc
Memory leaks

Index