Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/interface/ffi/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,16 @@ const TreeNode = struct {
module_name: []const u8,
restart_type: ChildRestartType,
shutdown_ms: u32,
// Tree structure
// Tree structure.
// `children` holds non-owning references to other nodes; every node is
// owned exactly once by the handle's flat `nodes` list (see OtpiserHandle).
children: std.ArrayList(*TreeNode),
allocator: std.mem.Allocator,

/// Release only this node's own resources. Children are NOT freed here:
/// they are owned by the handle's `nodes` list and freed there exactly
/// once, avoiding the double-free that arises from dual ownership.
fn deinit(self: *TreeNode) void {
for (self.children.items) |child| {
child.deinit();
self.allocator.destroy(child);
}
self.children.deinit();
}
};
Expand Down
Loading