[nq] Plug some memory leaks and fix a shutdown error

The error was introduced by the input memory leak fixes, but the
solution is to ensure CL_Shutdown is called before IN_Shutdown.

Some of the memory leaks were quite legitimate this time.
This commit is contained in:
Bill Currie 2022-05-12 20:15:19 +09:00
parent bc674657cb
commit 4e526702dd
8 changed files with 13 additions and 7 deletions

View file

@ -205,6 +205,8 @@ CL_ReadConfiguration (const char *cfg_name)
Qclose (cfg_file);
plitem_t *config = PL_GetPropertyList (cfg, 0);
free (cfg);
if (!config) {
return 0;
}
@ -620,8 +622,6 @@ CL_Init (cbuf_t *cbuf)
{
byte *basepal, *colormap;
Sys_RegisterShutdown (CL_Shutdown, 0);
basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
@ -662,6 +662,8 @@ CL_Init (cbuf_t *cbuf)
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view "
"to be level");
Sys_RegisterShutdown (CL_Shutdown, 0);
SZ_Alloc (&cls.message, 1024);
CL_SetState (ca_disconnected);
}

View file

@ -1012,6 +1012,7 @@ Host_ExecConfig (cbuf_t *cbuf, int skip_quakerc)
void
Host_Init (void)
{
Sys_RegisterShutdown (Host_Shutdown, 0);
Sys_Printf ("Host_Init\n");
host_cbuf = Cbuf_New (&id_interp);
@ -1052,6 +1053,8 @@ Host_Init (void)
con_module->data->console->realtime = &con_realtime;
con_module->data->console->frametime = &con_frametime;
con_module->data->console->quit = Host_Quit_f;
//FIXME need to rethink cbuf connections (they can form a stack)
Cbuf_DeleteStack (con_module->data->console->cbuf);
con_module->data->console->cbuf = host_cbuf;
}

View file

@ -1003,6 +1003,7 @@ sbar_update_vis (void)
void
Sbar_Draw (void)
{
if (!cl.players) return; //FIXME draw_miniteam
sbar_update_vis ();
hud_main_view->draw (hud_main_view);
}
@ -1491,6 +1492,11 @@ init_hud_views (void)
if (hud_frags_view)
view_add (hud_inventory_view, hud_frags_view);
if (minifrags_view)
view_add (hud_view, minifrags_view);
if (miniteam_view)
view_add (hud_view, miniteam_view);
view = view_new (0, 0, r_data->vid->conview->xlen, 48, grav_south);
view_add (view, hud_view);
hud_view = view;

View file

@ -113,7 +113,6 @@ SDL_main (int argc, char *argv[])
isDedicated = (COM_CheckParm ("-dedicated") != 0);
Sys_RegisterShutdown (Host_Shutdown, 0);
Sys_RegisterShutdown (shutdown_f, 0);
Host_Init ();

View file

@ -75,7 +75,6 @@ main (int argc, const char **argv)
isDedicated = (COM_CheckParm ("-dedicated") != 0);
Sys_RegisterShutdown (Host_Shutdown, 0);
Sys_RegisterShutdown (shutdown_f, 0);
Host_Init ();

View file

@ -86,7 +86,6 @@ main (int argc, const char **argv)
host_parms.argc = com_argc;
host_parms.argv = com_argv;
Sys_RegisterShutdown (Host_Shutdown, 0);
Sys_RegisterShutdown (shutdown_f, 0);
Host_Init ();

View file

@ -207,7 +207,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
if (!isDedicated)
init_handles (hInstance);
Sys_RegisterShutdown (Host_Shutdown, 0);
Sys_RegisterShutdown (shutdown_f, 0);
Host_Init ();

View file

@ -69,7 +69,6 @@ main (int argc, const char **argv)
host_parms.argc = com_argc;
host_parms.argv = com_argv;
Sys_RegisterShutdown (Host_Shutdown, 0);
Sys_RegisterShutdown (shutdown_f, 0);
Host_Init ();