Skip to content

Commit

Permalink
feat(memory-pools): finalize implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yamafaktory committed Nov 30, 2024
1 parent 4922ce5 commit bfd4bbc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/hypergraphz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ pub fn HypergraphZ(comptime H: type, comptime V: type) type {
const vertex = self.vertices.getPtr(v);
// A vertex can appear multiple times within a hyperedge and thus might already be deleted.
if (vertex) |ptr| {
// Remove from the vertices pool.
self.vertices_pool.destroy(@alignCast(ptr.data));

// Release memory.
ptr.relations.deinit();
const removed = self.vertices.orderedRemove(v);
Expand All @@ -418,6 +421,9 @@ pub fn HypergraphZ(comptime H: type, comptime V: type) type {
}
}

// Remove from the hyperedges pool.
self.hyperedges_pool.destroy(hyperedge.data);

// Release memory.
hyperedge.relations.deinit();

Expand Down Expand Up @@ -450,6 +456,9 @@ pub fn HypergraphZ(comptime H: type, comptime V: type) type {
std.mem.swap(ArrayList(HypergraphZId), &hyperedge.relations, &tmp);
}

// Remove from the vertices pool.
self.vertices_pool.destroy(@alignCast(vertex.data));

// Release memory.
vertex.relations.deinit();

Expand Down

0 comments on commit bfd4bbc

Please sign in to comment.