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. */
| 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. */ |
| 2319 | static 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. */ |
no outgoing calls
no test coverage detected