MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / raxDefragStackPush

Function raxDefragStackPush

server/src/server/rax.c:2319–2349  ·  view source on GitHub ↗

Push a new node into the defragmentation iterator stack. The parent_child * argument is the child index of this node in its parent, or -1 for the * radix tree head. Return 1 on success or 0 on out of memory. */

Source from the content-addressed store, hash-verified

2317 * argument is the child index of this node in its parent, or -1 for the
2318 * radix tree head. Return 1 on success or 0 on out of memory. */
2319static inline int raxDefragStackPush(raxDefragIterator *it, raxNode *node,
2320 int parent_child)
2321{
2322 if (it->items == it->maxitems) {
2323 if (it->stack == it->static_items) {
2324 it->stack = rax_malloc(sizeof(*it->stack)*it->maxitems*2);
2325 if (it->stack == NULL) {
2326 it->stack = it->static_items;
2327 errno = ENOMEM;
2328 return 0;
2329 }
2330 memcpy(it->stack,it->static_items,sizeof(*it->stack)*it->maxitems);
2331 } else {
2332 raxDefragFrame *newalloc =
2333 rax_realloc(it->stack,sizeof(*it->stack)*it->maxitems*2);
2334 if (newalloc == NULL) {
2335 errno = ENOMEM;
2336 return 0;
2337 }
2338 it->stack = newalloc;
2339 }
2340 it->maxitems *= 2;
2341 }
2342
2343 it->stack[it->items].node = node;
2344 it->stack[it->items].child = 0;
2345 it->stack[it->items].parent_child = parent_child;
2346 it->stack[it->items].state = RAX_DEFRAG_STATE_EMIT_NODE;
2347 it->items++;
2348 return 1;
2349}
2350
2351/* Return the frame at the top of the defragmentation stack, or NULL if there
2352 * are no more nodes to visit. */

Callers 2

raxDefragStartFunction · 0.85
raxDefragNextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected