Mercurial > molko
diff libmlk-core/core/alloc.h @ 252:95c2c4a72410
core: add alloc_set to set SDL allocators as well
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 01 Dec 2020 21:53:23 +0100 |
parents | 71b3b7036de7 |
children | c4da052c0def |
line wrap: on
line diff
--- a/libmlk-core/core/alloc.h Tue Dec 01 21:53:00 2020 +0100 +++ b/libmlk-core/core/alloc.h Tue Dec 01 21:53:23 2020 +0100 @@ -42,9 +42,9 @@ #define ALLOC_POOL_INIT_DEFAULT 32 /** - * \brief Global allocator strategy. + * \brief Allocator functions. */ -struct allocator { +struct alloc_funcs { /** * (+) Allocate some data. * @@ -119,9 +119,18 @@ }; /** - * \brief Global allocator object. + * Set custom allocator functions. + * + * The alloc_funcs struct must stay valid until the program is closed. + * + * \pre funcs != NULL + * \pre funcs->alloc != NULL + * \pre funcs->realloc != NULL + * \pre funcs->free != NULL + * \param funcs the functions */ -extern struct allocator allocator; +void +alloc_set(const struct alloc_funcs *funcs); /** * Shortcut for allocator->alloc.