From 72ef60c8c2f8ec8098e2ccdf6256c1b29e0e5915 Mon Sep 17 00:00:00 2001 From: Aaron Winter Date: Sun, 27 Nov 2022 04:53:44 +0100 Subject: [PATCH] ecs: fix segfault in Entities.deinit (#629) Co-authored-by: Aaron Winter --- libs/ecs/src/entities.zig | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/ecs/src/entities.zig b/libs/ecs/src/entities.zig index 69e6bb80..251c0718 100644 --- a/libs/ecs/src/entities.zig +++ b/libs/ecs/src/entities.zig @@ -470,7 +470,7 @@ pub fn Entities(comptime all_components: anytype) type { .len = 0, .capacity = 0, .columns = columns, - .block = undefined, + .block = &[_]u8{}, .hash = void_archetype_hash, }); @@ -587,7 +587,7 @@ pub fn Entities(comptime all_components: anytype) type { .len = 0, .capacity = 0, .columns = columns, - .block = undefined, + .block = &[_]u8{}, .hash = undefined, }; @@ -715,7 +715,7 @@ pub fn Entities(comptime all_components: anytype) type { .len = 0, .capacity = 0, .columns = columns, - .block = undefined, + .block = &[_]u8{}, .hash = undefined, }; @@ -867,3 +867,11 @@ test "example" { // Remove an entity whenever you wish. Just be sure not to try and use it later! try world.remove(player1); } + +test "empty_world" { + const allocator = testing.allocator; + //------------------------------------------------------------------------- + var world = try Entities(.{}).init(allocator); + // Create a world. + defer world.deinit(); +} \ No newline at end of file