Skip to content

Commit

Permalink
Use malloc/free for file list items (#311)
Browse files Browse the repository at this point in the history
For Quake installs with lots of mods containing large pak files the changes in b37e57f 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.
  • Loading branch information
andrei-drexler committed Apr 2, 2024
1 parent 7101804 commit b444798
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -131,7 +131,7 @@ static void FileList_Clear (filelist_item_t **list)
while (*list)
{
blah = (*list)->next;
Z_Free(*list);
free (*list);
*list = blah;
}
}
Expand Down

0 comments on commit b444798

Please sign in to comment.