mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2025-01-18 22:41:49 +00:00
Fix possible memory leak in menu font and crosshair loading.
This commit is contained in:
parent
3da6641b19
commit
2959cb730a
3 changed files with 19 additions and 9 deletions
|
@ -194,7 +194,7 @@ typedef struct
|
|||
// This can be used to load script files, etc
|
||||
// Also support open, read/write and closing files
|
||||
#ifdef KMQUAKE2_ENGINE_MOD
|
||||
char **(*ListPak) (char *find, int *num);
|
||||
char **(*ListPak) (char *find, int *num); // Deprecated- DO NOT USE!
|
||||
int (*LoadFile) (char *name, void **buf);
|
||||
void (*FreeFile) (void *buf);
|
||||
void (*FreeFileList) (char **list, int n);
|
||||
|
|
|
@ -101,8 +101,8 @@ Font loading
|
|||
*/
|
||||
cvar_t *con_font;
|
||||
#define MAX_FONTS 32
|
||||
char **font_names;
|
||||
int numfonts;
|
||||
char **font_names = NULL;
|
||||
int numfonts = 0;
|
||||
|
||||
static void FontSizeFunc( void *unused )
|
||||
{
|
||||
|
@ -348,6 +348,11 @@ void Options_Interface_MenuInit ( void )
|
|||
s_options_interface_menualpha_slider.maxvalue = 20;
|
||||
s_options_interface_menualpha_slider.generic.statusbar = "changes opacity of menu background";
|
||||
|
||||
// free any loaded fonts to prevent memory leak
|
||||
if (numfonts > 0) {
|
||||
FS_FreeFileList (font_names, numfonts);
|
||||
}
|
||||
numfonts = 0;
|
||||
font_names = SetFontNames ();
|
||||
s_options_interface_font_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_interface_font_box.generic.x = 0;
|
||||
|
|
|
@ -97,8 +97,8 @@ Crosshair loading
|
|||
*/
|
||||
|
||||
#define MAX_CROSSHAIRS 100
|
||||
char **crosshair_names;
|
||||
int numcrosshairs;
|
||||
char **crosshair_names = NULL;
|
||||
int numcrosshairs = 0;
|
||||
|
||||
/*static void OldCrosshairFunc( void *unused )
|
||||
{
|
||||
|
@ -343,6 +343,11 @@ void Options_Screen_MenuInit ( void )
|
|||
s_options_screen_header.generic.x = MENU_FONT_SIZE/2 * strlen(s_options_screen_header.generic.name);
|
||||
s_options_screen_header.generic.y = 0;
|
||||
|
||||
// free any loaded crosshairs to prevent memory leak
|
||||
if (numcrosshairs > 0) {
|
||||
FS_FreeFileList (crosshair_names, numcrosshairs);
|
||||
}
|
||||
numcrosshairs = 0;
|
||||
crosshair_names = SetCrosshairNames ();
|
||||
s_options_screen_crosshair_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_screen_crosshair_box.generic.x = 0;
|
||||
|
|
Loading…
Reference in a new issue