Re: why no palloc() ("permanent alloc")?

Barry Margolin <barmar@xxxxxxxxxxxx> writes:

The warnings aren't about unreachable pointers, they're for pointers
that are never freed. They're needed until the end of the program, so
he's happy with letting the system free them when the process exits.
But valgrind doesn't know this.

Actually, valgrind knows this perfectly well, and wouldn't be quite
as useful as it is if it didn't:

#include <stdlib.h>
void *reachable;
int main()
void *leaked = malloc(10);
reachable = malloc(20);
return 0;

$ gcc -g t.c && valgrind ./a.out

==13228== LEAK SUMMARY:
*> ==13228== definitely lost: 10 bytes in 1 blocks.
==13228== possibly lost: 0 bytes in 0 blocks.
*> ==13228== still reachable: 20 bytes in 1 blocks.
==13228== suppressed: 0 bytes in 0 blocks.
==13228== Use --leak-check=full to see details of leaked memory.

In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.