fixing couple of small memory leaks

This commit is contained in:
David Carlier 2017-08-27 01:00:57 +01:00
parent 50b0e97332
commit 9f71d55258
3 changed files with 24 additions and 0 deletions

View file

@ -585,3 +585,24 @@ Cvar_Init(void)
Cmd_AddCommand("cvarlist", Cvar_List_f); Cmd_AddCommand("cvarlist", Cvar_List_f);
} }
/*
* Free list of cvars
*/
void
Cvar_Fini(void)
{
cvar_t *var;
for (var = cvar_vars; var;)
{
cvar_t *c = var;
Z_Free(var->string);
Z_Free(var->name);
Z_Free(var);
var = c->next;
}
Cmd_RemoveCommand("cvarlist");
Cmd_RemoveCommand("set");
}

View file

@ -475,6 +475,8 @@ void Cvar_WriteVariables(char *path);
void Cvar_Init(void); void Cvar_Init(void);
void Cvar_Fini(void);
char *Cvar_Userinfo(void); char *Cvar_Userinfo(void);
/* returns an info string containing all the CVAR_USERINFO cvars */ /* returns an info string containing all the CVAR_USERINFO cvars */

View file

@ -411,5 +411,6 @@ Qcommon_Frame(int msec)
void void
Qcommon_Shutdown(void) Qcommon_Shutdown(void)
{ {
Cvar_Fini();
} }