akgl_heap_release* should not cascade into dependent objects (releasing actors should not release characters, sprites, and spritesheets)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
13
src/heap.c
13
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);
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user