From c1fa6e2956ed5520fde067f61a49618ba541698f Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 12 Jul 2023 02:19:32 +0200 Subject: [PATCH] now creating world array with 16 elements if world array length is 0 --- src/corelib/world.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/world.c b/src/corelib/world.c index a7ce34b..e2457eb 100644 --- a/src/corelib/world.c +++ b/src/corelib/world.c @@ -14,6 +14,9 @@ struct { static inline int _expand_world() { size_t new_num = _world_objects.num * 2; + if(new_num == 0) { + new_num = 16; + } object_t** new_list = realloc(_world_objects.objects, new_num * sizeof(object_t*)); if(new_list == NULL) { printf("ERROR: failed to expand world when requesting additional objects\n");