Merge pull request #63 from BeWorld2018/fix

Fix memory leak on exit
This commit is contained in:
Dominic Szablewski 2023-09-01 14:11:44 +02:00 committed by GitHub
commit 9e90c4768f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -247,9 +247,6 @@ uint32_t platform_store_userdata(const char *name, void *bytes, int32_t len) {
return file_store(path, bytes, len);
}
#if defined(RENDERER_GL) // ----------------------------------------------------
#define PLATFORM_WINDOW_FLAGS SDL_WINDOW_OPENGL
SDL_GLContext platform_gl;
@ -299,7 +296,10 @@ uint32_t platform_store_userdata(const char *name, void *bytes, int32_t len) {
}
void platform_video_cleanup() {
if (screenbuffer) {
SDL_DestroyTexture(screenbuffer);
}
SDL_DestroyRenderer(renderer);
}
void platform_prepare_frame() {
@ -339,8 +339,6 @@ uint32_t platform_store_userdata(const char *name, void *bytes, int32_t len) {
#error "Unsupported renderer for platform SDL"
#endif
int main(int argc, char *argv[]) {
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
@ -418,6 +416,12 @@ int main(int argc, char *argv[]) {
system_cleanup();
platform_video_cleanup();
SDL_DestroyWindow(window);
if (gamepad) {
SDL_GameControllerClose(gamepad);
}
if (sdl_path_assets) {
SDL_free(sdl_path_assets);
}