A pointer to the buffer, which will be reallocated if necessary.
The function also adds *pos to the end of the headers in the buffer.