Am I reconstructing the buffers correctly
This is the wrong way to sue realloc:

returnBuffer = (char*)realloc(returnBuffer, requestedBufferSize);


If it fails you have just leaked the old returnBuffer.
The way realloc should be used is:

char* tmp = (char*)realloc(returnBuffer, requestedBufferSize);
if (tmp != NULL)
{
    returnBuffer = tmp;
}
else { /* Deal with realloc() failure */ }


But why are you dealing with this. I would use a std::vector&lt;char&gt; it deals with all the memory management issues for you (and your post id tagged C++).

TO be honest I have trouble following the rest of your code.