From: tomaz Date: Mon, 3 Jan 2005 15:47:00 +0000 (+0000) Subject: Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem) X-Git-Tag: xonotic-v0.1.0preview~5245 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=ac947d2fbb445473c266390a1fca26c8be8611c4 Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4897 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cgamevm.c b/cgamevm.c index f3250df1..e2b33f4d 100644 --- a/cgamevm.c +++ b/cgamevm.c @@ -26,6 +26,11 @@ void CL_CGVM_Init(void) cgvm_mempool = Mem_AllocPool("CGVM", 0, NULL); } +void CL_CGVM_Shutdown(void) +{ + Mem_FreePool (&cgvm_mempool); +} + void CL_CGVM_Clear(void) { Mem_EmptyPool(cgvm_mempool); diff --git a/cgamevm.h b/cgamevm.h index 75ce188d..f5f0887e 100644 --- a/cgamevm.h +++ b/cgamevm.h @@ -3,6 +3,7 @@ #define CGAMEVM_H void CL_CGVM_Init(void); +void CL_CGVM_Shutdown(void); void CL_CGVM_Clear(void); void CL_CGVM_Frame(void); void CL_CGVM_Start(void); diff --git a/cl_main.c b/cl_main.c index 8f244af9..041247d1 100644 --- a/cl_main.c +++ b/cl_main.c @@ -1307,6 +1307,12 @@ CL_Shutdown */ void CL_Shutdown (void) { + CL_CGVM_Shutdown(); + CL_Particles_Shutdown(); + CL_Parse_Shutdown(); + + SZ_Free (&cls.message); + Mem_FreePool (&cl_entities_mempool); Mem_FreePool (&cl_refdef_mempool); } diff --git a/cl_parse.c b/cl_parse.c index 8629ba12..262b0863 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1758,3 +1758,8 @@ void CL_Parse_Init(void) Cvar_SetValue("demo_nehahra", 1); Cvar_RegisterVariable(&developer_networkentities); } + +void CL_Parse_Shutdown(void) +{ + Mem_FreePool (&cl_scores_mempool); +} diff --git a/cl_particles.c b/cl_particles.c index bdf1d44c..2278100a 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -371,6 +371,15 @@ void CL_Particles_Init (void) CL_Particles_Clear(); } +void CL_Particles_Shutdown (void) +{ +#ifdef WORKINGLQUAKE + // No clue what to do here... +#else + Mem_FreePool (&cl_part_mempool); +#endif +} + // list of all 26 parameters: // ptype - any of the pt_ enum values (pt_static, pt_blood, etc), see ptype_t near the top of this file // porientation - PARTICLE_ enum values (PARTICLE_BILLBOARD, PARTICLE_SPARK, etc) diff --git a/client.h b/client.h index c70640e5..f634a223 100644 --- a/client.h +++ b/client.h @@ -743,6 +743,7 @@ void CL_TimeDemo_f(void); // cl_parse.c // void CL_Parse_Init(void); +void CL_Parse_Shutdown(void); void CL_ParseServerMessage(void); void CL_Parse_DumpPacket(void); @@ -790,6 +791,7 @@ extern cvar_t cl_decals_fadetime; void CL_Particles_Clear(void); void CL_Particles_Init(void); +void CL_Particles_Shutdown(void); void CL_ParseParticleEffect (void); void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count); diff --git a/cmd.c b/cmd.c index f8c3f1fc..18ac78fe 100644 --- a/cmd.c +++ b/cmd.c @@ -77,6 +77,15 @@ void Cbuf_Init (void) SZ_Alloc (&cmd_text, 32768, "command buffer"); // space for commands and script files } +/* +============ +Cbuf_Shutdown +============ +*/ +void Cbuf_Shutdown (void) +{ + SZ_Free (&cmd_text); +} /* ============ diff --git a/cmd.h b/cmd.h index c05f7062..66ab6af0 100644 --- a/cmd.h +++ b/cmd.h @@ -40,6 +40,8 @@ The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute (); void Cbuf_Init (void); // allocates an initial text buffer that will grow as needed +void Cbuf_Shutdown (void); + void Cbuf_AddText (const char *text); // as new commands are generated from the console or keybindings, // the text is added to the end of the command buffer. diff --git a/common.c b/common.c index 1414e31f..b45c9968 100644 --- a/common.c +++ b/common.c @@ -1014,6 +1014,17 @@ void COM_Init (void) COM_CheckRegistered (); } +extern void FS_Shutdown (void); + +/* +================ +COM_Shutdown +================ +*/ +void COM_Shutdown (void) +{ + FS_Shutdown (); +} /* ============ diff --git a/common.h b/common.h index aa2d29d5..d58387ba 100644 --- a/common.h +++ b/common.h @@ -174,6 +174,7 @@ extern const char **com_argv; int COM_CheckParm (const char *parm); void COM_Init (void); +void COM_Shutdown (void); void COM_InitArgv (void); void COM_InitGameType (void); diff --git a/fs.c b/fs.c index 218a85e4..376336b7 100644 --- a/fs.c +++ b/fs.c @@ -1041,6 +1041,16 @@ void FS_Init (void) unlink (va("%s/qconsole.log", fs_gamedir)); } +/* +================ +FS_Shutdown +================ +*/ +void FS_Shutdown (void) +{ + Mem_FreePool (&pak_mempool); + Mem_FreePool (&fs_mempool); +} /* ==================== diff --git a/host.c b/host.c index f5cb873f..c7f92fa2 100644 --- a/host.c +++ b/host.c @@ -1016,6 +1016,9 @@ void Host_Shutdown(void) CDAudio_Shutdown (); S_Terminate (); NetConn_Shutdown (); + PR_Shutdown (); + COM_Shutdown (); + Cbuf_Shutdown (); if (cls.state != ca_dedicated) { @@ -1027,5 +1030,6 @@ void Host_Shutdown(void) CL_Shutdown(); Sys_Shutdown(); Log_Close (); + Memory_Shutdown(); } diff --git a/menu.c b/menu.c index 9111bd36..de17fe6f 100644 --- a/menu.c +++ b/menu.c @@ -4174,6 +4174,8 @@ void M_Shutdown(void) { // reset key_dest key_dest = key_game; + + Mem_FreePool (&menu_mempool); } void M_Restart(void) diff --git a/pr_cmds.c b/pr_cmds.c index a8886449..e7289720 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -3742,6 +3742,11 @@ void PR_Cmd_Init(void) PR_Search_Init(); } +void PR_Cmd_Shutdown(void) +{ + Mem_FreePool (&pr_strings_mempool); +} + void PR_Cmd_Reset(void) { Mem_EmptyPool(pr_strings_mempool); diff --git a/pr_edict.c b/pr_edict.c index 2ea21f97..c789469f 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -1676,6 +1676,20 @@ void PR_Init (void) PR_Cmd_Init(); } +/* +=============== +PR_Shutdown +=============== +*/ +extern void PR_Cmd_Shutdown(void); +void PR_Shutdown (void) +{ + PR_Cmd_Shutdown(); + + Mem_FreePool(&edictstring_mempool); + Mem_FreePool(&progs_mempool); +} + // LordHavoc: turned EDICT_NUM into a #define for speed reasons edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline) { diff --git a/progs.h b/progs.h index cdae2523..4fb9f4f3 100644 --- a/progs.h +++ b/progs.h @@ -159,6 +159,7 @@ extern int pr_edictareasize; // LordHavoc: for bounds checking //============================================================================ void PR_Init (void); +void PR_Shutdown (void); void PR_ExecuteProgram (func_t fnum, const char *errormessage); void PR_LoadProgs (const char *progsname); diff --git a/zone.c b/zone.c index f58aa54a..bba361cc 100644 --- a/zone.c +++ b/zone.c @@ -433,6 +433,12 @@ void Memory_Init (void) poolchain = NULL; } +void Memory_Shutdown (void) +{ +// Mem_FreePool (&zonemempool); +// Mem_FreePool (&tempmempool); +} + void Memory_Init_Commands (void) { Cmd_AddCommand ("memstats", MemStats_f); diff --git a/zone.h b/zone.h index f1417350..3410c0ec 100644 --- a/zone.h +++ b/zone.h @@ -138,6 +138,7 @@ qboolean Mem_IsAllocated(mempool_t *pool, void *data); mempool_t *tempmempool; void Memory_Init (void); +void Memory_Shutdown (void); void Memory_Init_Commands (void); extern mempool_t *zonemempool;