#endif
unsigned offset; /* points to the first unused byte in the buffer */
unsigned size; /* size of the buffer */
- void *ralloc_parent; /* new buffers will use this */
struct linear_header *next; /* next buffer if we have more */
struct linear_header *latest; /* the only buffer that has free space */
#endif
node->offset = 0;
node->size = min_size;
- node->ralloc_parent = ralloc_ctx;
node->next = NULL;
node->latest = node;
return node;
if (unlikely(latest->offset + full_size > latest->size)) {
/* allocate a new node */
- new_node = create_linear_node(latest->ralloc_parent, size);
+ void *ralloc_ctx = ralloc_parent_of_linear_parent(parent);
+ new_node = create_linear_node(ralloc_ctx, size);
if (unlikely(!new_node))
return NULL;
while (node) {
ralloc_steal(new_ralloc_ctx, node);
- node->ralloc_parent = new_ralloc_ctx;
node = node->next;
}
}
{
linear_header *node = LINEAR_PARENT_TO_HEADER(ptr);
assert(node->magic == LMAGIC);
- return node->ralloc_parent;
+ return PTR_FROM_HEADER(get_header(node)->parent);
}
void *