mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
fix a memory leak happening when there's no loading gamestate registered
This commit is contained in:
parent
2b3a2e3d72
commit
6e8670bf12
2 changed files with 11 additions and 9 deletions
|
@ -162,15 +162,17 @@ SYMBOL_INTERNAL void UnfreezeGamestates(struct Game* game) {
|
|||
SYMBOL_INTERNAL void ResizeGamestates(struct Game* game) {
|
||||
struct Gamestate* tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
al_destroy_bitmap(tmp->fb);
|
||||
if (game->_priv.params.handlers.compositor) {
|
||||
tmp->fb = CreateNotPreservedBitmap(game->clip_rect.w, game->clip_rect.h);
|
||||
} else {
|
||||
tmp->fb = al_create_sub_bitmap(al_get_backbuffer(game->display), game->clip_rect.x, game->clip_rect.y, game->clip_rect.w, game->clip_rect.h);
|
||||
if (tmp->open) {
|
||||
al_destroy_bitmap(tmp->fb);
|
||||
if (game->_priv.params.handlers.compositor) {
|
||||
tmp->fb = CreateNotPreservedBitmap(game->clip_rect.w, game->clip_rect.h);
|
||||
} else {
|
||||
tmp->fb = al_create_sub_bitmap(al_get_backbuffer(game->display), game->clip_rect.x, game->clip_rect.y, game->clip_rect.w, game->clip_rect.h);
|
||||
}
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (game->_priv.loading.gamestate) {
|
||||
if (game->_priv.loading.gamestate && game->_priv.loading.gamestate->open) {
|
||||
al_destroy_bitmap(game->_priv.loading.gamestate->fb);
|
||||
if (game->_priv.params.handlers.compositor) {
|
||||
game->_priv.loading.gamestate->fb = CreateNotPreservedBitmap(game->clip_rect.w, game->clip_rect.h);
|
||||
|
@ -411,6 +413,7 @@ 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;
|
||||
}
|
||||
|
@ -420,7 +423,6 @@ SYMBOL_INTERNAL void CloseGamestate(struct Game* game, struct Gamestate* gamesta
|
|||
dlclose(gamestate->handle);
|
||||
#endif
|
||||
}
|
||||
free(gamestate->name);
|
||||
if (gamestate->api) {
|
||||
free(gamestate->api);
|
||||
}
|
||||
|
|
|
@ -485,10 +485,10 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
|
|||
tmp = pom;
|
||||
}
|
||||
|
||||
if (game->_priv.loading.gamestate->open) {
|
||||
if (game->_priv.loading.gamestate->api) {
|
||||
(*game->_priv.loading.gamestate->api->unload)(game, game->_priv.loading.gamestate->data);
|
||||
CloseGamestate(game, game->_priv.loading.gamestate);
|
||||
}
|
||||
CloseGamestate(game, game->_priv.loading.gamestate);
|
||||
free(game->_priv.loading.gamestate);
|
||||
|
||||
if (game->_priv.params.handlers.destroy) {
|
||||
|
|
Loading…
Reference in a new issue