Simplified declarations

This commit is contained in:
2026-09-12 11:54:53 -05:00
parent c1c603a250
commit c9ffbe13f1
5 changed files with 14 additions and 82 deletions
+2 -16
View File
@@ -94,28 +94,14 @@ typedef struct {
* virtual table for itself. Other objects which implement this, may * virtual table for itself. Other objects which implement this, may
* come with member variables. * come with member variables.
*/ */
typedef struct { define_struct(allocator) {
/** /**
* @brief A pointer to an immutable allocator virtual function table. * @brief A pointer to an immutable allocator virtual function table.
* @details Contains the function pointers to the allocator specific functions * @details Contains the function pointers to the allocator specific functions
* that make this allocator function as one. * that make this allocator function as one.
*/ */
const allocator_vtable_t* vtable; const allocator_vtable_t* vtable;
} allocator_t; };
/**
* @brief A pointer to a mutable allocator.
* @details This is provided to simplify type declarations for functions
* requiring allocators that are meant to be mutable.
*/
typedef allocator_t* allocator_mptr_t;
/**
* @brief A pointer to a immutable allocator view.
* @details This is provided to simplify type declarations for functions
* requiring allocators that are meant to be immutable.
*/
typedef const allocator_t* allocator_iptr_t;
/** /**
+3 -16
View File
@@ -24,29 +24,16 @@
/** /**
* @struct arena_allocator
* @brief Defines a concrete arena allocator. * @brief Defines a concrete arena allocator.
* @details An arena allocator is a type of large push allocator. It simply * @details An arena allocator is a type of large push allocator. It simply
* obtains large regions of memory, rounded up to the next operating * obtains large regions of memory, rounded up to the next operating
* system page size, and pushes data onto those pages without any * system page size, and pushes data onto those pages without any
* understanding of how to dispose that data later. * understanding of how to dispose that data later.
*/ */
typedef struct { define_struct(arena_allocator) {
malunal_size_t __opaque[2]; malunal_size_t __opaque[2];
} arena_allocator_t; };
/**
* @brief A pointer to a mutable arena allocator.
* @details This is provided to simplify type declarations for functions
* requiring arena allocators that are meant to be mutable.
*/
typedef arena_allocator_t* arena_allocator_mptr_t;
/**
* @brief A pointer to an immutable arena allocator.
* @details This is provided to simplify type declarations for functions
* requiring arena allocators that are meant to be immutable.
*/
typedef const arena_allocator_t* arena_allocator_iptr_t;
/** /**
* @brief Obtains the size of the arena allocator. * @brief Obtains the size of the arena allocator.
+3 -16
View File
@@ -11,28 +11,15 @@
#define MALUNAL_ALLOCATORS_LINEAR_HEADER #define MALUNAL_ALLOCATORS_LINEAR_HEADER
/** /**
* @struct linear_allocator
* @brief Defines a concrete linear allocator. * @brief Defines a concrete linear allocator.
* @details Linear allocators, also called bump allocators, simply track small * @details Linear allocators, also called bump allocators, simply track small
* acquisitions into the buffer that is provided to it. It does this * acquisitions into the buffer that is provided to it. It does this
* by knowing how much memory * by knowing how much memory
*/ */
typedef struct { define_struct(linear_allocator) {
malunal_size_t __opaque[4]; malunal_size_t __opaque[4];
} linear_allocator_t; };
/**
* @brief A pointer to a mutable linear allocator.
* @details This is provided to simplify type declarations for functions
* requiring linear allocators that are meant to be mutable.
*/
typedef linear_allocator_t* linear_allocator_mptr_t;
/**
* @brief A pointer to an immutable linear allocator.
* @details This is provided to simplify type declarations for functions
* requiring linear allocators that are meant to be immutable.
*/
typedef const linear_allocator_t* linear_allocator_iptr_t;
/** /**
* @brief Obtains the size of the linear allocator. * @brief Obtains the size of the linear allocator.
+3 -17
View File
@@ -11,6 +11,7 @@
#define MALUNAL_ALLOCATORS_POOL_HEADER #define MALUNAL_ALLOCATORS_POOL_HEADER
/** /**
* @struct pool_allocator
* @brief Defines a concrete pool allocator. * @brief Defines a concrete pool allocator.
* @details A pool allocator is a type of free listing allocator. It obtains * @details A pool allocator is a type of free listing allocator. It obtains
* some underlying memory region and divides it up into chunks that * some underlying memory region and divides it up into chunks that
@@ -20,24 +21,9 @@
* The pool allocator will automatically upsize the stride to a multiple * The pool allocator will automatically upsize the stride to a multiple
* of two when initializing the pool. * of two when initializing the pool.
*/ */
typedef struct { define_struct(pool_allocator) {
malunal_size_t __opaque[7]; malunal_size_t __opaque[7];
} pool_allocator_t; };
/**
* @brief A pointer to a mutable pool allocator.
* @details This is provided to simplify type declarations for functions
* requiring pool allocators that are meant to be mutable.
*/
typedef pool_allocator_t* pool_allocator_mptr_t;
/**
* @brief A pointer to an immutable pool allocator.
* @details This is provided to simplify type declarations for functions
* requiring pool allocators that are meant to be immutable.
*/
typedef const pool_allocator_t* pool_allocator_iptr_t;
/** /**
* @brief Obtains the stride of the pool allocator. * @brief Obtains the stride of the pool allocator.
+3 -17
View File
@@ -11,6 +11,7 @@
#define MALUNAL_ALLOCATORS_STACK_HEADER #define MALUNAL_ALLOCATORS_STACK_HEADER
/** /**
* @struct stack_allocator
* @brief Defines a concrete stack allocator. * @brief Defines a concrete stack allocator.
* @details A stack allocator is one that acquires and disposes in a first in * @details A stack allocator is one that acquires and disposes in a first in
* last out manner. This is useful for temporary stacks and some * last out manner. This is useful for temporary stacks and some
@@ -19,24 +20,9 @@
* disposed must be the last acquired address or the allocator will * disposed must be the last acquired address or the allocator will
* fail to dispose it. * fail to dispose it.
*/ */
typedef struct { define_struct(stack_allocator) {
malunal_size_t __opaque[6]; malunal_size_t __opaque[6];
} stack_allocator_t; };
/**
* @brief A pointer to a mutable stack allocator.
* @details This is provided to simplify type declarations for functions
* requiring stack allocators that are meant to be mutable.
*/
typedef stack_allocator_t* stack_allocator_mptr_t;
/**
* @brief A pointer to an immutable stack allocator.
* @details This is provided to simplify type declarations for functions
* requiring stack allocators that are meant to be immutable.
*/
typedef const stack_allocator_t* stack_allocator_iptr_t;
/** /**
* @brief Obtains the stride of the stack allocator. * @brief Obtains the stride of the stack allocator.