From ca47a517ae11766acfc98f2bb642b4bc511bb2ba Mon Sep 17 00:00:00 2001 From: Quinn Date: Sun, 16 Feb 2025 19:12:02 +0100 Subject: [PATCH] fix: add freeing at the end of main, and don't call exit in update --- src/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index b9dc9ee..2ab8af6 100644 --- a/src/main.c +++ b/src/main.c @@ -2,7 +2,6 @@ #include #include #include -#include #include "error.h" #include "game/game.h" @@ -30,7 +29,7 @@ static void update(void) { while (SDL_PollEvent(&e)) { switch (e.type) { case SDL_QUIT: - exit(STATUS_SUCCESS); + set_gamestatus(STATUS_SUCCESS); break; } } @@ -50,5 +49,11 @@ int32_t main(int32_t argc, char** argv) { while (get_gamestatus() == STATUS_RUNNING) update(); + game_free(&gdat); + render_free(&rdat); + gdat = (gamedata){0}; + rdat = (renderdata){0}; + SDL_Quit(); + return get_gamestatus(); }