From 08c85ebae06db7d2d587a5a89877f7594db2a662 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 16 Mar 2023 00:39:25 +0100 Subject: [PATCH] SDL_test: introduce SDLTest_CommonDestroyState to only destroy SDLTest_CommonState --- include/SDL3/SDL_test_common.h | 9 ++++++++- src/test/SDL_test_common.c | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/SDL3/SDL_test_common.h b/include/SDL3/SDL_test_common.h index daed5c0a6..84dd18aee 100644 --- a/include/SDL3/SDL_test_common.h +++ b/include/SDL3/SDL_test_common.h @@ -122,7 +122,7 @@ typedef struct int gl_debug; int gl_profile_mask; - /* Additional fields added in 2.0.18 */ + /* Mouse info */ SDL_Rect confine; } SDLTest_CommonState; @@ -145,6 +145,13 @@ extern "C" { */ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); +/** + * \brief Free the common state object. + * + * \param state The common state object to destroy + */ +void SDLTest_CommonDestroyState(SDLTest_CommonState *state); + /** * \brief Process one common argument. * diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index cd4831f3f..acb93fbf7 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -118,6 +118,12 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags) return state; } +void +SDLTest_CommonDestroyState(SDLTest_CommonState *state) { + SDLTest_LogAllocations(); + SDL_free(state); +} + #define SEARCHARG(dim) \ while (*(dim) && *(dim) != ',') { \ ++(dim); \ @@ -2261,9 +2267,8 @@ void SDLTest_CommonQuit(SDLTest_CommonState *state) if (state->flags & SDL_INIT_AUDIO) { SDL_QuitSubSystem(SDL_INIT_AUDIO); } - SDL_free(state); SDL_Quit(); - SDLTest_LogAllocations(); + SDLTest_CommonDestroyState(state); } void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, float *usedHeight)