From 48a8a797460ea5fdbb98d9c7c77e8a835e38e4ba Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 10 Feb 2018 18:23:08 +0100 Subject: [PATCH] Fix some memory leaks --- src/main.c | 14 +++++++++++++- src/text.c | 16 ++++++++++++++++ src/text.h | 2 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 27949bac..3d96e27d 100644 --- a/src/main.c +++ b/src/main.c @@ -951,6 +951,7 @@ int Init_program(int argc,char * argv[]) // ------------------------- Fermeture du programme -------------------------- void Program_shutdown(void) { + int i; int return_code; // Windows only: Recover the window position. @@ -1008,7 +1009,18 @@ void Program_shutdown(void) } else Error(ERROR_MISSING_DIRECTORY); - + + // Free Config +#define FREE_POINTER(p) free(p); p = NULL + FREE_POINTER(Config.Skin_file); + FREE_POINTER(Config.Font_file); + for (i=0;iNext; + free(font_list_start->Name); + free(font_list_start); + font_list_start = font; + } +} #ifndef NOTTF byte *Render_text_TTF(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height, T_Palette palette) diff --git a/src/text.h b/src/text.h index 6d65b274..15b537a6 100644 --- a/src/text.h +++ b/src/text.h @@ -27,6 +27,8 @@ /// Initialization of text settings, needs to be called once on program startup. void Init_text(void); +/// text settings cleanup. called on program shutdown +void Uninit_text(void); /// Returns true if text.c was compiled with TrueType support. int TrueType_is_supported(void); /// Add a new font to the list to propose to the user.