]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem)
authortomaz <tomaz@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 3 Jan 2005 15:47:00 +0000 (15:47 +0000)
committertomaz <tomaz@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 3 Jan 2005 15:47:00 +0000 (15:47 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4897 d7cf8633-e32d-0410-b094-e92efae38249

18 files changed:
cgamevm.c
cgamevm.h
cl_main.c
cl_parse.c
cl_particles.c
client.h
cmd.c
cmd.h
common.c
common.h
fs.c
host.c
menu.c
pr_cmds.c
pr_edict.c
progs.h
zone.c
zone.h

index f3250df194a551832129146ce52bd41f08b89824..e2b33f4df8c743456d165b7b886ed72c68fd2bf5 100644 (file)
--- 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);
index 75ce188d6b5fe2f6e06f4465bb8db777f0f9be7d..f5f0887e4b220e75d7532c484138ce9a107b840a 100644 (file)
--- 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);
index 8f244af96edb799d35343819b7c34dc6113b81ae..041247d1f8039d23d6449687e1b9833d2282f747 100644 (file)
--- 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);
 }
index 8629ba125f5a2e710b5c052b2c5e1c5d8c0e6669..262b08636b43a9a5d4b27dc38061c759f4086b41 100644 (file)
@@ -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);
+}
index bdf1d44c68f469ab1cb7b03702dad0057695b0d1..2278100ac3e9e0ae0b438f372a818d1cc0bd9230 100644 (file)
@@ -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)
index c70640e5e18ff0595613bb6fd8774d7d25429e29..f634a223c81c292031df08293c84db613997b1be 100644 (file)
--- 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 f8c3f1fcf633fd42eab313aa570b777d106d87c7..18ac78fe5bb7d851756ca2dd69b5b9f527572a5c 100644 (file)
--- 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 c05f7062fbaf2566c0116b64488ce7173c277338..66ab6af0219d4458b27fae557831c2572737ac58 100644 (file)
--- 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.
index 1414e31f6f074951812ee66140cbe9e5e0915bad..b45c99689f2f0c07568ce328095bd62c5461316c 100644 (file)
--- 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 ();
+}
 
 /*
 ============
index aa2d29d5b804b1648cd2540316ce569ae469a714..d58387bac33caa98ca1763f2f4df528a9abc75e1 100644 (file)
--- 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 218a85e4b6dd3410e9617e4fea7d7f6d37b4b32c..376336b7cf199156d526464c2faa6306dd659089 100644 (file)
--- 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 f5cb873f1b72d8f184944fe938d29a082658e8f9..c7f92fa24b914f0efe17bbf26f7ff718ce6d5b45 100644 (file)
--- 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 9111bd36c385ef64ab854297e08ec1e8ce3b845d..de17fe6f0b22cc2518a65f9f53b5daf6376328a7 100644 (file)
--- 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)
index a888644932c9317dd1caedcb41e493f68c293394..e7289720460ac58696c2fda7b01e841a41f342f2 100644 (file)
--- 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);
index 2ea21f97ffde0ba94e64756c11d6b2d90e3174cd..c789469f4979a2e32c9bedc66b8ce81bf0905b07 100644 (file)
@@ -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 cdae2523cc26b9c59913ae88313c9a5777049c9c..4fb9f4f3bc9c705c9addbb142bc13f286de0213b 100644 (file)
--- 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 f58aa54a38a94d8356088ecb87dfd5834d9ca862..bba361cc1ff29f390bb9c84520615e03f5bdcb29 100644 (file)
--- 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 f1417350b1f946931a1f440b848bd683c13d3774..3410c0ecc226517e61843e99d6a2e3af6d3303ab 100644 (file)
--- 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;