From aad196d84ee118c5146e17f4014fd85878dfa07f Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Wed, 13 May 2026 22:45:52 -0400 Subject: [PATCH] akgl_heap_release* should not cascade into dependent objects (releasing actors should not release characters, sprites, and spritesheets) --- include/akgl/SDL_GameControllerDB.h | 2 +- src/heap.c | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/akgl/SDL_GameControllerDB.h b/include/akgl/SDL_GameControllerDB.h index d0dacc7..f680c47 100644 --- a/include/akgl/SDL_GameControllerDB.h +++ b/include/akgl/SDL_GameControllerDB.h @@ -1,7 +1,7 @@ #ifndef _SDL_GAMECONTROLLERDB_H_ #define _SDL_GAMECONTROLLERDB_H_ -// Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Wed May 13 07:27:47 PM EDT 2026 +// Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Wed May 13 10:44:28 PM EDT 2026 #define AKGL_SDL_GAMECONTROLLER_DB_LEN 2228 diff --git a/src/heap.c b/src/heap.c index ac5f21c..dbc9d25 100644 --- a/src/heap.c +++ b/src/heap.c @@ -118,9 +118,6 @@ akerr_ErrorContext *akgl_heap_release_actor(akgl_Actor *ptr) CATCH_AND_RETURN(errctx, akgl_heap_release_actor(ptr->children[i])); } } - if ( ptr->basechar != NULL ) { - CATCH_AND_RETURN(errctx, akgl_heap_release_character(ptr->basechar)); - } SDL_ClearProperty(AKGL_REGISTRY_ACTOR, (char *)&ptr->name); memset(ptr, 0x00, sizeof(akgl_Actor)); } @@ -133,14 +130,13 @@ akerr_ErrorContext *akgl_heap_release_character(akgl_Character *basechar) akgl_Iterator opflags; FAIL_ZERO_RETURN(errctx, basechar, AKERR_NULLPOINTER, "NULL character reference"); AKGL_BITMASK_CLEAR(opflags.flags); - AKGL_BITMASK_ADD(opflags.flags, AKGL_ITERATOR_OP_RELEASE); if ( basechar->refcount > 0 ) { basechar->refcount -= 1; } if ( basechar->refcount == 0 ) { - SDL_EnumerateProperties(basechar->state_sprites, &akgl_character_state_sprites_iterate, (void *)&opflags); SDL_ClearProperty(AKGL_REGISTRY_CHARACTER, (char *)&basechar->name); + memset(basechar, 0x00, sizeof(akgl_Character)); } SUCCEED_RETURN(errctx); } @@ -153,12 +149,8 @@ akerr_ErrorContext *akgl_heap_release_sprite(akgl_Sprite *ptr) ptr->refcount -= 1; } if ( ptr->refcount == 0 ) { - ATTEMPT { - CATCH(errctx, akgl_heap_release_spritesheet(ptr->sheet)); - } CLEANUP { - SDL_ClearProperty(AKGL_REGISTRY_SPRITE, (char *)&ptr->name); - } PROCESS(errctx) { - } FINISH(errctx, true); + SDL_ClearProperty(AKGL_REGISTRY_SPRITE, (char *)&ptr->name); + memset(ptr, 0x00, sizeof(akgl_Sprite)); } SUCCEED_RETURN(errctx); } @@ -176,6 +168,7 @@ akerr_ErrorContext *akgl_heap_release_spritesheet(akgl_SpriteSheet *ptr) if ( ptr-> texture != NULL ) SDL_DestroyTexture(ptr->texture); ptr->texture = NULL; + memset(ptr, 0x00, sizeof(akgl_SpriteSheet)); } SUCCEED_RETURN(errctx); }