use m_array for file handles

This commit is contained in:
Roman Fomin 2024-01-10 22:37:08 +07:00
parent 849eb0ed71
commit 1c1b3f1e8f

View File

@ -84,8 +84,7 @@ void ExtractFileBase(const char *path, char *dest)
// Reload hack removed by Lee Killough // Reload hack removed by Lee Killough
// //
static int *handles; static int *handles = NULL;
static int num_handles;
static void W_AddFile(const char *name) // killough 1/31/98: static, const static void W_AddFile(const char *name) // killough 1/31/98: static, const
{ {
@ -151,8 +150,7 @@ static void W_AddFile(const char *name) // killough 1/31/98: static, const
numlumps += header.numlumps; numlumps += header.numlumps;
} }
handles = I_Realloc(handles, (num_handles + 1) * sizeof(*handles)); array_push(handles, handle);
handles[num_handles++] = handle;
free(filename); // killough 11/98 free(filename); // killough 11/98
@ -630,7 +628,7 @@ void W_CloseFileDescriptors(void)
{ {
int i; int i;
for (i = 0; i < num_handles; ++i) for (i = 0; i < array_size(handles); ++i)
{ {
close(handles[i]); close(handles[i]);
} }