From 6b4ed304a68930ee2ef567e56295ca38fbeedbeb Mon Sep 17 00:00:00 2001 From: CodeHz Date: Thu, 3 Sep 2020 09:07:06 +0000 Subject: [PATCH] fix iterate hashmap --- zig-ecs/src/ecs/registry.zig | 3 ++- zig-ecs/src/ecs/type_store.zig | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/zig-ecs/src/ecs/registry.zig b/zig-ecs/src/ecs/registry.zig index b049414..9703202 100644 --- a/zig-ecs/src/ecs/registry.zig +++ b/zig-ecs/src/ecs/registry.zig @@ -195,7 +195,8 @@ pub const Registry = struct { } pub fn deinit(self: *Registry) void { - for (self.components.items()) |ptr| { + var iter = self.components.iterator(); + while (iter.next()) |ptr| { // HACK: we dont know the Type here but we need to call deinit var storage = @intToPtr(*Storage(u1), ptr.value); storage.deinit(); diff --git a/zig-ecs/src/ecs/type_store.zig b/zig-ecs/src/ecs/type_store.zig index 21db41f..a16704d 100644 --- a/zig-ecs/src/ecs/type_store.zig +++ b/zig-ecs/src/ecs/type_store.zig @@ -14,7 +14,8 @@ pub const TypeStore = struct { } pub fn deinit(self: *TypeStore) void { - for (self.map.items()) |kv| { + var iter = self.map.iterator(); + while (iter.next()) |kv| { self.allocator.free(kv.value); } self.map.deinit();