Add array allocations to larena

This commit is contained in:
Nils O. Selåsdal
2026-05-24 23:34:34 +02:00
parent 6185de0694
commit e306a9fed0
+5
View File
@@ -94,9 +94,14 @@ struct LArenaTemp {
* struct foo *foo = LARENA_ALLOC_TYPE(&my_allocator, struct foo);
* // Array types can be used too:
* 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
*/
#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
static inline size_t larena_size(const LArena *arena)
{