From b44479827dcdd6493de902efbca12110f7840316 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Wed, 3 Apr 2024 00:43:11 +0200 Subject: [PATCH] Use malloc/free for file list items (#311) For Quake installs with lots of mods containing large pak files the changes in b37e57f6 ended up fragmenting the zone buffer due to a repeated pattern of temporarily allocating larger buffers for the pak files, followed by a small persistent allocation for the mod info, followed by pak file deallocation. Switching the file list items from zone allocation to general-purpose malloc avoids this pathological case. --- Quake/host_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index 905db1dc0..3c55993d4 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -76,7 +76,7 @@ static filelist_item_t *FileList_AddWithData (const char *name, const void *data return item; } - item = (filelist_item_t *) Z_Malloc(sizeof(filelist_item_t) + datasize); + item = (filelist_item_t *) malloc (sizeof(filelist_item_t) + datasize); q_strlcpy (item->name, name, sizeof(item->name)); if (datasize) { @@ -131,7 +131,7 @@ static void FileList_Clear (filelist_item_t **list) while (*list) { blah = (*list)->next; - Z_Free(*list); + free (*list); *list = blah; } }