From a8fa3e4da0d81325bb64a5dfdc986553d1d2a8da Mon Sep 17 00:00:00 2001 From: Gregory Wells Date: Tue, 17 Jun 2025 11:58:14 -0400 Subject: [PATCH] more array list functions --- utils/lists/gryphn_array_list.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/lists/gryphn_array_list.h b/utils/lists/gryphn_array_list.h index 09b8997..e011fc7 100644 --- a/utils/lists/gryphn_array_list.h +++ b/utils/lists/gryphn_array_list.h @@ -20,6 +20,18 @@ int newCount = count - (list->maxSize - list->count);\ list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \ list->maxSize += newCount; \ }\ +inline static void type##ArrayListExpand(type##ArrayList* list, int count) { \ +list->data = realloc(list->data, sizeof(type) * (count + list->maxSize)); \ +list->maxSize += count; \ +}\ +inline static void type##ArrayListAdd(type##ArrayList* list, type data) { \ +if (list->count >= list->maxSize) {\ + list->maxSize *= 2; \ + list->data = realloc(list->data, sizeof(type) * list->maxSize); \ +} \ +list->data[list->count] = data;\ +list->count++;\ +}\ inline static void type##ArrayListResize(type##ArrayList* list, int count) { \ int newCount = count - (list->maxSize - list->count);\ list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \