2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @file heap.h
|
|
|
|
|
* @brief Declares the public heap API.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
#ifndef _AKGL_HEAP_H_
|
|
|
|
|
#define _AKGL_HEAP_H_
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
#include "sprite.h"
|
|
|
|
|
#include "actor.h"
|
|
|
|
|
#include "character.h"
|
|
|
|
|
#include "staticstring.h"
|
2026-01-05 08:58:06 -05:00
|
|
|
#include <akerror.h>
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-08 10:16:33 -04:00
|
|
|
#ifndef AKGL_MAX_HEAP_ACTOR
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_MAX_HEAP_ACTOR 64
|
2026-05-08 10:16:33 -04:00
|
|
|
#endif
|
|
|
|
|
#ifndef AKGL_MAX_HEAP_SPRITE
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_MAX_HEAP_SPRITE (AKGL_MAX_HEAP_ACTOR * 16)
|
2026-05-08 10:16:33 -04:00
|
|
|
#endif
|
|
|
|
|
#ifndef AKGL_MAX_HEAP_SPRITESHEET
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_MAX_HEAP_SPRITESHEET AKGL_MAX_HEAP_SPRITE
|
2026-05-08 10:16:33 -04:00
|
|
|
#endif
|
|
|
|
|
#ifndef AKGL_MAX_HEAP_CHARACTER
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_MAX_HEAP_CHARACTER 256
|
2026-05-08 10:16:33 -04:00
|
|
|
#endif
|
|
|
|
|
#ifndef AKGL_MAX_HEAP_STRING
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_MAX_HEAP_STRING 256
|
2026-05-08 10:16:33 -04:00
|
|
|
#endif
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-07-30 01:10:31 -04:00
|
|
|
/** @brief Fixed-capacity actor object pool. */
|
2026-05-06 23:18:42 -04:00
|
|
|
extern akgl_Actor HEAP_ACTOR[AKGL_MAX_HEAP_ACTOR];
|
2026-07-30 01:10:31 -04:00
|
|
|
/** @brief Fixed-capacity sprite object pool. */
|
2026-05-06 23:18:42 -04:00
|
|
|
extern akgl_Sprite HEAP_SPRITE[AKGL_MAX_HEAP_SPRITE];
|
2026-07-30 01:10:31 -04:00
|
|
|
/** @brief Fixed-capacity spritesheet object pool. */
|
2026-05-06 23:18:42 -04:00
|
|
|
extern akgl_SpriteSheet HEAP_SPRITESHEET[AKGL_MAX_HEAP_SPRITESHEET];
|
2026-07-30 01:10:31 -04:00
|
|
|
/** @brief Fixed-capacity character object pool. */
|
2026-05-06 23:18:42 -04:00
|
|
|
extern akgl_Character HEAP_CHARACTER[AKGL_MAX_HEAP_CHARACTER];
|
2026-07-30 01:10:31 -04:00
|
|
|
/** @brief Fixed-capacity static-string object pool. */
|
2026-05-06 23:18:42 -04:00
|
|
|
extern akgl_String HEAP_STRING[AKGL_MAX_HEAP_STRING];
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap init.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKGL_ERR_BEHAVIOR When the corresponding validation or operation fails.
|
|
|
|
|
* @throws AKGL_ERR_HEAP When the corresponding validation or operation fails.
|
|
|
|
|
* @throws AKGL_ERR_LOGICINTERRUPT When the corresponding validation or operation fails.
|
|
|
|
|
* @throws AKGL_ERR_REGISTRY When the corresponding validation or operation fails.
|
|
|
|
|
* @throws AKGL_ERR_SDL When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_init();
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap init actor.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKERR_* Propagates an error reported by a delegated operation.
|
|
|
|
|
*/
|
2026-05-25 21:29:18 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_init_actor();
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap next actor.
|
|
|
|
|
* @param dest Output destination populated by the function.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKGL_ERR_HEAP When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_next_actor(akgl_Actor **dest);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap next sprite.
|
|
|
|
|
* @param dest Output destination populated by the function.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKGL_ERR_HEAP When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_next_sprite(akgl_Sprite **dest);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap next spritesheet.
|
|
|
|
|
* @param dest Output destination populated by the function.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKGL_ERR_HEAP When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_next_spritesheet(akgl_SpriteSheet **dest);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap next character.
|
|
|
|
|
* @param dest Output destination populated by the function.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKGL_ERR_HEAP When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_next_character(akgl_Character **dest);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap next string.
|
|
|
|
|
* @param dest Output destination populated by the function.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKGL_ERR_HEAP When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_next_string(akgl_String **dest);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap release actor.
|
|
|
|
|
* @param ptr Heap object whose reference count is decremented.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKERR_NULLPOINTER When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_release_actor(akgl_Actor *ptr);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap release sprite.
|
|
|
|
|
* @param ptr Heap object whose reference count is decremented.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKERR_NULLPOINTER When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_release_sprite(akgl_Sprite *ptr);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap release spritesheet.
|
|
|
|
|
* @param ptr Heap object whose reference count is decremented.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKERR_NULLPOINTER When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_release_spritesheet(akgl_SpriteSheet *ptr);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap release character.
|
|
|
|
|
* @param ptr Heap object whose reference count is decremented.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKERR_NULLPOINTER When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_release_character(akgl_Character *ptr);
|
2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Heap release string.
|
|
|
|
|
* @param ptr Heap object whose reference count is decremented.
|
|
|
|
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
|
|
|
|
* @throws AKERR_NULLPOINTER When the corresponding validation or operation fails.
|
|
|
|
|
*/
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_heap_release_string(akgl_String *ptr);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
#endif //_AKGL_HEAP_H_
|