From ff565e8d422c5e58558d1f7682ba0c9756e5be27 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 14 Jul 2025 09:30:08 -0700 Subject: Add function to allocate aligned blocks on the memstack --- memstack/include/memstack.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'memstack/include/memstack.h') diff --git a/memstack/include/memstack.h b/memstack/include/memstack.h index 9a8a7ee..97a9d12 100644 --- a/memstack/include/memstack.h +++ b/memstack/include/memstack.h @@ -33,13 +33,23 @@ void memstack_del(memstack*); void memstack_clear(memstack*); /// Allocate a new block. +/// /// Return null if the block does not fit in the remaining memory. +/// /// When there is no space left in the stack, allocation can either trap /// (default) or gracefully return null. Call mem_enable_traps() to toggle this /// behaviour. +/// /// Newly allocated blocks are conveniently zeroed out. void* memstack_alloc(memstack*, size_t bytes); +/// Allocate a new aligned block. +/// +/// An alignment of 0 is allowed for convenience and has the same effect as 1. +/// +/// Has the same properties as memstack_alloc(). +void* memstack_alloc_aligned(memstack*, size_t bytes, size_t alignment); + /// Return the stack's used size in bytes. size_t memstack_size(const memstack*); -- cgit v1.2.3