Skip to content

GraphDeinit

Description

Release every node, every edge list, and the backing slot storage of g. If the graph was created with a deep-copy deinit callback, that callback is invoked on each live node payload before the slot is freed.

Parameters

Name Direction Description
g in,out Graph to deinitialize. Must not be used until reinitialized.

Success

All node payloads released, all edge bookkeeping freed; g left in the zeroed post-deinit state.

Failure

Cannot fail; aborts on a corrupted magic via the validator.

Usage example (Cross-references)

Usage examples (Cross-references)
        result = result && !GraphNodeVisited(node) && (GraphNodeVisitCount(node) == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && !GraphNodeVisited(GraphGetNode(&graph, d));
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphNodeCount(&graph) == 1);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (GraphPredecessorAt(&graph, c, 0) == a);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphEdgeCount(&graph) == 1);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphInDegree(&graph, c) == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphInDegree(&graph, a) == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphInDegree(&graph, d) == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result                           = result && (GraphNodeAt(&graph, reused) == 99);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        (void)GraphNodeVisit(node);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        result      = result && (GraphNodeCount(&graph) == 2);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result        = result && (GraphNodeCount(&graph) == 1);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result        = result && (GraphNodeCount(&graph) == 1);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (GraphInDegree(&graph, c) == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        (void)GraphEdgeMarkedForRemoval(&graph, a, b);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphEdgeMarkedForRemoval(&graph, a, b);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphUnmarkEdgeForRemoval(&graph, a, b);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphUnmarkEdgeForRemoval(&graph, a, b);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        GENERIC_GRAPH(&graph)->__magic    &= ~MAGIC_VALIDATED_BIT;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && GraphContainsNode(&graph, c);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && GraphNodeMarkedForDeletion(GraphGetNode(&graph, c));
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        StrDeinit(&name);
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
                      ZstrCompare(StrBegin(stored_name), "alpha") == 0;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (graph_h.pending_edge_removals.allocator->retry_limit == 31);
    
        GraphDeinit(&graph_a);
        GraphDeinit(&graph_b);
        GraphDeinit(&graph_c);
    
        GraphDeinit(&graph_a);
        GraphDeinit(&graph_b);
        GraphDeinit(&graph_c);
        GraphDeinit(&graph_d);
        GraphDeinit(&graph_a);
        GraphDeinit(&graph_b);
        GraphDeinit(&graph_c);
        GraphDeinit(&graph_d);
        GraphDeinit(&graph_e);
        GraphDeinit(&graph_b);
        GraphDeinit(&graph_c);
        GraphDeinit(&graph_d);
        GraphDeinit(&graph_e);
        GraphDeinit(&graph_f);
        GraphDeinit(&graph_c);
        GraphDeinit(&graph_d);
        GraphDeinit(&graph_e);
        GraphDeinit(&graph_f);
        GraphDeinit(&graph_g);
        GraphDeinit(&graph_d);
        GraphDeinit(&graph_e);
        GraphDeinit(&graph_f);
        GraphDeinit(&graph_g);
        GraphDeinit(&graph_h);
        GraphDeinit(&graph_e);
        GraphDeinit(&graph_f);
        GraphDeinit(&graph_g);
        GraphDeinit(&graph_h);
        GraphDeinit(&graph_f);
        GraphDeinit(&graph_g);
        GraphDeinit(&graph_h);
    
        HeapAllocatorDeinit(&aligned_64);
        result      = result && (VecCapacity(&graph.slots) >= 64);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
    // Mark (but do not commit) an edge removal so a backing exists at teardown.
    static bool test_deinit_frees_pending_edge_removals_backing_no_leak(void) {
        WriteFmt("Testing GraphDeinit frees the pending-edge-removals backing (no leak)\n");
    
        DebugAllocator dbg = DebugAllocatorInit();
        GraphMarkEdgeForRemoval(&graph, a, b); // pending_edge_removals gains backing
    
        GraphDeinit(&graph);                   // deinit_vec(pending_edge_removals) frees the array
    
        bool ok = LEAK_CLEAN(dbg);
        result      = result && GraphNodeAt(&graph, id1) == 7;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && GraphPredecessorAt(&graph, c, 0) == a;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphPredecessorAt(&graph, a, 2) == c);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphMutationEpoch(&graph) > old_epoch);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphMutationEpoch(&graph) > old_epoch);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphNodeCount(&graph) == 2);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && !GraphContainsNode(&graph, b);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (GraphNodeCount(&graph) == 0);
    
        GraphDeinit(&graph);
        DebugAllocatorDeinit(&dbg);
        return result;
        result = result && (GraphNodeCount(&graph) == 1);
    
        GraphDeinit(&graph);
        DebugAllocatorDeinit(&dbg);
        return result;
                      GraphMutationEpoch(&graph) == 0 && GraphAllocator(&graph)->alignment == 1;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && GraphContainsNode(&graph, node_id);
    
        GraphDeinit(&graph);
        HeapAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphNodeCount(&graph) == 3);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        ValidateGraph(&graph);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
    
        MapDeinit(&index);
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        MapDeinit(&counts);
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphInDegree(&graph, a) == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        }
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        }
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        }
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        bool result = (visited == 2);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (GraphNodeCount(&graph) == 2);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        (void)graph_neighbor_iter_next(&iter, &out);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)graph_predecessor_iter_next(&iter, &out);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        }
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        }
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        }
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        bool result = (visited == 1);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && GraphPredecessorAt(&graph, c, 0) == a;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (ZstrCompare(*GraphNodePtrAt(&graph, red), "red") == 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        (void)GraphNodeData(&graph_b, node);
    
        GraphDeinit(&graph_b);
        GraphDeinit(&graph_a);
        DefaultAllocatorDeinit(&alloc);
    
        GraphDeinit(&graph_b);
        GraphDeinit(&graph_a);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphPredecessorAt(&graph, a, 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphNeighborAt(&graph, b, 0);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        graph.slots.length += 1;
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result                   = result && !GraphContainsNode(&graph, free_slot_id);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return result;
        (void)GraphGetNode(&graph, b);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphGetNode(&graph, a);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphHasEdge(&graph, a, bogus_to);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphNodeAt(&graph, a);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
        (void)GraphGetNode(&graph, free_match);
    
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        return false;
Last updated on