It makes sense. If it were me I would write this out in C++ just to keep my code looking cleaner. But I am a C guy, so no harm doing it all in C
Here is how I typically handle this stuff, lugnut, and see if this is of more help:
Example:
Code:
char *pool = malloc(4096), *p; // Lets just pretend like the 4k is allocated no problem.
struct myheader *h1;
struct myotherheader *h2;
// after peforming some sort of reading function that fills up pool's 4k of data.
p = pool;
// Lets say the first piece if information in your file is the offset of the first header..
p += *(size_t *)p;
h1 = (void *)p;
p = (h1 + 1) + h1->comment_length;
h2 = (void *)p;
I find it easier to have one pointer that processes the entire data chunk in terms of bytes (or sometimes dwords) then have it scout out where the headers are supposed to exist.