fix only one hook working per event (I forgot to zero the memory)

This commit is contained in:
Squibid 2025-12-12 17:34:22 -05:00
parent 2da4e1e938
commit 7a619ab770
Signed by: squibid
GPG key ID: BECE5684D3C4005D

View file

@ -25,10 +25,8 @@ pub fn put(self: *Events, key: []const u8, hook: *const Hook) !void {
ll = sll; ll = sll;
} else { } else {
ll = try self.allocator.create(std.SinglyLinkedList); ll = try self.allocator.create(std.SinglyLinkedList);
ll.* = .{};
try self.events.put(key, ll); try self.events.put(key, ll);
if (self.events.get(key)) |sll| {
ll = sll;
}
} }
const data = try self.allocator.create(Node); const data = try self.allocator.create(Node);
data.* = .{ data.* = .{
@ -47,10 +45,6 @@ pub fn exec(self: *Events, event: []const u8, args: anytype) void {
while (node) |n| : (node = n.next) { while (node) |n| : (node = n.next) {
const data: *Node = @fieldParentPtr("node", n); const data: *Node = @fieldParentPtr("node", n);
data.hook.callback(args); data.hook.callback(args);
// FIXME: not sure why but for some reason our ll doesn't seem to want to
// admit that there's nothing after the first node.
break;
} }
} }
} }