GraphReserve
Description
Reserve space for at least n nodes in the graph. Does not change the node count, only ensures capacity.
Parameters
| Name | Direction | Description |
|---|---|---|
g |
in,out | Graph handle. |
n |
in | Minimum number of nodes the graph should accommodate. |
Success
Returns true. The slot array and free-index array now have capacity for at least n total nodes without triggering a regrow. live_count and the actual stored nodes are unchanged.
Failure
Returns false on allocation failure for either backing array. The graph is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Graph.Init.c:11:
static bool test_graph_reserve_clear(void) {
WriteFmt("Testing GraphReserve and GraphClear\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Graph.Init.c:18:
IntGraph graph = GraphInit(&alloc);
GraphReserve(&graph, 8);
ValidateGraph(&graph);- In
Memory.h:60:
#define GraphMustReserve(g, n) \
do { \
if (!GraphReserve((g), (n))) { \
LOG_FATAL("GraphMustReserve failed"); \
} \
Last updated on