diff options
Diffstat (limited to 'include/rune/core/alloc.h')
-rw-r--r-- | include/rune/core/alloc.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/rune/core/alloc.h b/include/rune/core/alloc.h index 35170d8..65121ce 100644 --- a/include/rune/core/alloc.h +++ b/include/rune/core/alloc.h @@ -25,6 +25,9 @@ #include <rune/util/types.h> #include <rune/util/list.h> +/** + * Memory block used for memory accounting + */ struct mem_block { void *ptr; size_t sz; @@ -32,10 +35,40 @@ struct mem_block { struct list_head list; }; +/** + * \brief Custom malloc implementation + * \param[in] sz The size of the requested memory block + * \return A pointer to void, or NULL in case of error + */ RAPI void* rune_alloc(size_t sz); + +/** + * \brief Custom calloc implementation + * \param[in] nmemb An integer to fill the memory block with + * \param[in] sz The size of the requested memory block + * \return A pointer to void, or NULL in case of error + */ RAPI void* rune_calloc(size_t nmemb, size_t sz); + +/** + * \brief Custom realloc implementation + * \param[in] ptr A void pointer to a previously alloc'd block, or NULL + * \param[in] sz The size of the requested memory block + * \return A pointer to void, or NULL in case of error + */ RAPI void* rune_realloc(void *ptr, size_t sz); + +/** + * \brief Custom free implementation + * \param[in] ptr A void pointer to a previously alloc'd block + */ RAPI void rune_free(void *ptr); + +/** + * \brief Used to free all memory currently in use by the engine + * This function should only be used at the end of execution, and is normally + * called by rune_exit. + */ RAPI void rune_free_all(void); #endif |