Add array allocations to larena
This commit is contained in:
@@ -94,9 +94,14 @@ struct LArenaTemp {
|
|||||||
* struct foo *foo = LARENA_ALLOC_TYPE(&my_allocator, struct foo);
|
* struct foo *foo = LARENA_ALLOC_TYPE(&my_allocator, struct foo);
|
||||||
* // Array types can be used too:
|
* // Array types can be used too:
|
||||||
* struct Foo *str = LARENA_ALLOC_TYPE(&my_allocator, struct Foo[32]);
|
* struct Foo *str = LARENA_ALLOC_TYPE(&my_allocator, struct Foo[32]);
|
||||||
|
* // For arrays with runtime determined size, use:
|
||||||
|
* LARENA_ALLOC_ARRAY(&my_allocator, struct Foo, cnt_foos);
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#define LARENA_ALLOC_TYPE(allocator, type_) larena_alloc_aligned((allocator), sizeof(type_), _Alignof(type_))
|
#define LARENA_ALLOC_TYPE(allocator, type_) larena_alloc_aligned((allocator), sizeof(type_), _Alignof(type_))
|
||||||
|
|
||||||
|
#define LARENA_ALLOC_ARRAY(allocator, type_, nr_elements) larena_alloc_aligned((allocator), nr_elements * sizeof(type_), _Alignof(type_))
|
||||||
|
|
||||||
// Arena size in bytes
|
// Arena size in bytes
|
||||||
static inline size_t larena_size(const LArena *arena)
|
static inline size_t larena_size(const LArena *arena)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user