From 7f04a7963ad5066353fcd74092d9221545094407 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 13 Dec 2017 21:14:03 +0300 Subject: [PATCH] added destructors for modules --- src/studio.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/studio.c b/src/studio.c index ff5837b..a760fd1 100644 --- a/src/studio.c +++ b/src/studio.c @@ -2504,20 +2504,20 @@ static void onFSInitialized(FileSystem* fs) studio.tic = studio.tic80local->memory; { - studio.start = SDL_malloc(sizeof(Start)); - studio.console = SDL_malloc(sizeof(Console)); - studio.run = SDL_malloc(sizeof(Run)); - studio.code = SDL_malloc(sizeof(Code)); - studio.sprite = SDL_malloc(sizeof(Sprite)); - studio.map = SDL_malloc(sizeof(Map)); - studio.world = SDL_malloc(sizeof(World)); - studio.sfx = SDL_malloc(sizeof(Sfx)); - studio.music = SDL_malloc(sizeof(Music)); - studio.config = SDL_malloc(sizeof(Config)); - studio.keymap = SDL_malloc(sizeof(Keymap)); - studio.dialog = SDL_malloc(sizeof(Dialog)); - studio.menu = SDL_malloc(sizeof(Menu)); - studio.surf = SDL_malloc(sizeof(Surf)); + studio.start = SDL_malloc(sizeof(Start)); + studio.console = SDL_malloc(sizeof(Console)); + studio.run = SDL_malloc(sizeof(Run)); + studio.code = SDL_malloc(sizeof(Code)); + studio.sprite = SDL_malloc(sizeof(Sprite)); + studio.map = SDL_malloc(sizeof(Map)); + studio.world = SDL_malloc(sizeof(World)); + studio.sfx = SDL_malloc(sizeof(Sfx)); + studio.music = SDL_malloc(sizeof(Music)); + studio.config = SDL_malloc(sizeof(Config)); + studio.keymap = SDL_malloc(sizeof(Keymap)); + studio.dialog = SDL_malloc(sizeof(Dialog)); + studio.menu = SDL_malloc(sizeof(Menu)); + studio.surf = SDL_malloc(sizeof(Surf)); } fsMakeDir(fs, TIC_LOCAL); @@ -2611,6 +2611,23 @@ s32 main(s32 argc, char **argv) #endif + { + SDL_free(studio.start); + SDL_free(studio.console); + SDL_free(studio.run); + SDL_free(studio.code); + SDL_free(studio.sprite); + SDL_free(studio.map); + SDL_free(studio.world); + SDL_free(studio.sfx); + SDL_free(studio.music); + SDL_free(studio.config); + SDL_free(studio.keymap); + SDL_free(studio.dialog); + SDL_free(studio.menu); + SDL_free(studio.surf); + } + if(studio.tic80local) tic80_delete((tic80*)studio.tic80local);