prof_buf
static void add_data_to_buffer(struct prof_buf *b, const void *d, size_t len)
add_data_to_buffer((struct prof_buf *)data, str, strlen(str));
struct prof_buf prof_buf = { 0, 0, 0, 0 };
dump_profile(root, 0, dump_profile_to_buffer_cb, &prof_buf);
if (prof_buf.err) {
add_data_to_buffer(&prof_buf, "", 1); /* append nul */
if (prof_buf.max - prof_buf.cur > (prof_buf.max >> 3)) {
char *newptr = realloc(prof_buf.base, prof_buf.cur);
prof_buf.base = newptr;
*buf = prof_buf.base;