diff --git a/include/larena.h b/include/larena.h index d98f1ae..a0b1823 100644 --- a/include/larena.h +++ b/include/larena.h @@ -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) {