SDL_test: introduce SDLTest_CommonDestroyState to only destroy SDLTest_CommonState

This commit is contained in:
Anonymous Maarten 2023-03-16 00:39:25 +01:00 committed by Anonymous Maarten
parent 5109e19935
commit 08c85ebae0
2 changed files with 15 additions and 3 deletions

View file

@ -122,7 +122,7 @@ typedef struct
int gl_debug; int gl_debug;
int gl_profile_mask; int gl_profile_mask;
/* Additional fields added in 2.0.18 */ /* Mouse info */
SDL_Rect confine; SDL_Rect confine;
} SDLTest_CommonState; } SDLTest_CommonState;
@ -145,6 +145,13 @@ extern "C" {
*/ */
SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); 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. * \brief Process one common argument.
* *

View file

@ -118,6 +118,12 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
return state; return state;
} }
void
SDLTest_CommonDestroyState(SDLTest_CommonState *state) {
SDLTest_LogAllocations();
SDL_free(state);
}
#define SEARCHARG(dim) \ #define SEARCHARG(dim) \
while (*(dim) && *(dim) != ',') { \ while (*(dim) && *(dim) != ',') { \
++(dim); \ ++(dim); \
@ -2261,9 +2267,8 @@ void SDLTest_CommonQuit(SDLTest_CommonState *state)
if (state->flags & SDL_INIT_AUDIO) { if (state->flags & SDL_INIT_AUDIO) {
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);
} }
SDL_free(state);
SDL_Quit(); SDL_Quit();
SDLTest_LogAllocations(); SDLTest_CommonDestroyState(state);
} }
void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, float *usedHeight) void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, float *usedHeight)