Freeing allocated memory: am I missing something?
The basic logic is that you only free dynamically allocated resources. Those that were created with malloc.

Hdr_t and body_t are automatically allocated and must therefore not be freed.

The most important point is that you might under no circumstances free a pointer without checking if it is not pointing to 0.

This following fragment will core:

void * ptr = 0;
free (ptr);


Therefore always do something like this:

if (ptr != 0)
    free(ptr)