mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
move freeing the gamestate's name outside of CloseGamestate
...and fixup the last commit
This commit is contained in:
parent
6e8670bf12
commit
3b3253ab6f
2 changed files with 5 additions and 3 deletions
|
@ -413,7 +413,6 @@ SYMBOL_INTERNAL struct Gamestate* AllocateGamestate(struct Game* game, const cha
|
|||
}
|
||||
|
||||
SYMBOL_INTERNAL void CloseGamestate(struct Game* game, struct Gamestate* gamestate) {
|
||||
free(gamestate->name);
|
||||
if (!gamestate->open) {
|
||||
return;
|
||||
}
|
||||
|
@ -421,12 +420,15 @@ SYMBOL_INTERNAL void CloseGamestate(struct Game* game, struct Gamestate* gamesta
|
|||
#ifndef LEAK_SANITIZER
|
||||
PrintConsole(game, "Closing gamestate \"%s\"...", gamestate->name);
|
||||
dlclose(gamestate->handle);
|
||||
gamestate->handle = NULL;
|
||||
#endif
|
||||
}
|
||||
if (gamestate->api) {
|
||||
free(gamestate->api);
|
||||
gamestate->api = NULL;
|
||||
}
|
||||
al_destroy_bitmap(gamestate->fb);
|
||||
gamestate->fb = NULL;
|
||||
}
|
||||
|
||||
SYMBOL_INTERNAL struct List* AddToList(struct List* list, void* data) {
|
||||
|
@ -619,9 +621,7 @@ SYMBOL_INTERNAL void ReloadCode(struct Game* game) {
|
|||
struct Gamestate* tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if (tmp->open && tmp->fromlib) {
|
||||
char* name = strdup(tmp->name);
|
||||
CloseGamestate(game, tmp);
|
||||
tmp->name = name;
|
||||
if (OpenGamestate(game, tmp, true) && LinkGamestate(game, tmp) && tmp->loaded) {
|
||||
if (tmp->api->reload) {
|
||||
PrintConsole(game, "[%s] Reloading...", tmp->name);
|
||||
|
|
|
@ -481,6 +481,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
|
|||
}
|
||||
CloseGamestate(game, tmp);
|
||||
pom = tmp->next;
|
||||
free(tmp->name);
|
||||
free(tmp);
|
||||
tmp = pom;
|
||||
}
|
||||
|
@ -489,6 +490,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
|
|||
(*game->_priv.loading.gamestate->api->unload)(game, game->_priv.loading.gamestate->data);
|
||||
}
|
||||
CloseGamestate(game, game->_priv.loading.gamestate);
|
||||
free(game->_priv.loading.gamestate->name);
|
||||
free(game->_priv.loading.gamestate);
|
||||
|
||||
if (game->_priv.params.handlers.destroy) {
|
||||
|
|
Loading…
Reference in a new issue