From aaca2d2ae7f2b2b2de4864b15b197bdc98e0cc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophyl=20Hoguet?= Date: Fri, 18 Mar 2022 19:13:27 +0100 Subject: [PATCH] fix a bit of memory leak --- CMakeLists.txt | 2 +- model.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f5f802..5e124a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ target_link_libraries(game_solve game) # game_sdl include_directories(${SDL2_ALL_INC}) add_executable(game_sdl main.c model.c) -target_link_libraries(game_sdl game ${SDL2_ALL_LIBS} m) +target_link_libraries(game_sdl game ${SDL2_ALL_LIBS}) # libgame add_library (game game.c game_aux.c game_ext.c game_private.c history.c game_tools.c game_examples.c) diff --git a/model.c b/model.c index a85fca7..6637e5b 100644 --- a/model.c +++ b/model.c @@ -392,17 +392,12 @@ void render(SDL_Window* win, SDL_Renderer* ren, Env* env) { bool process(SDL_Window* win, Env* env, SDL_Event* e) { int w, h; SDL_GetWindowSize(win, &w, &h); - if (e->type == SDL_QUIT) { return true; } - #ifdef _ANDROID_ #else - - else if (e->type == SDL_WINDOWEVENT) { - - } else if (e->type == SDL_MOUSEMOTION) { + if (e->type == SDL_MOUSEMOTION) { SDL_Point mouse; SDL_GetMouseState(&mouse.x, &mouse.y); if (SDL_PointInRect(&mouse, env->rec_restart)) { @@ -477,6 +472,9 @@ void clean(Env* env) { SDL_DestroyTexture(env->one[0]); SDL_DestroyTexture(env->one[1]); free(env->one); + SDL_DestroyTexture(env->two[0]); + SDL_DestroyTexture(env->two[1]); + free(env->two); SDL_DestroyTexture(env->three[0]); SDL_DestroyTexture(env->three[1]); free(env->three);