diff options
Diffstat (limited to 'memstack/include')
-rw-r--r-- | memstack/include/memstack.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/memstack/include/memstack.h b/memstack/include/memstack.h index 9a8a7ee..93cd2e6 100644 --- a/memstack/include/memstack.h +++ b/memstack/include/memstack.h | |||
@@ -32,14 +32,30 @@ void memstack_del(memstack*); | |||
32 | /// Clear the stack. | 32 | /// Clear the stack. |
33 | void memstack_clear(memstack*); | 33 | void memstack_clear(memstack*); |
34 | 34 | ||
35 | /// Return the top of the stack. | ||
36 | size_t memstack_watermark(const memstack*); | ||
37 | |||
38 | /// Set the top of the stack. | ||
39 | void memstack_set_watermark(memstack*, size_t watermark); | ||
40 | |||
35 | /// Allocate a new block. | 41 | /// Allocate a new block. |
42 | /// | ||
36 | /// Return null if the block does not fit in the remaining memory. | 43 | /// Return null if the block does not fit in the remaining memory. |
44 | /// | ||
37 | /// When there is no space left in the stack, allocation can either trap | 45 | /// When there is no space left in the stack, allocation can either trap |
38 | /// (default) or gracefully return null. Call mem_enable_traps() to toggle this | 46 | /// (default) or gracefully return null. Call mem_enable_traps() to toggle this |
39 | /// behaviour. | 47 | /// behaviour. |
48 | /// | ||
40 | /// Newly allocated blocks are conveniently zeroed out. | 49 | /// Newly allocated blocks are conveniently zeroed out. |
41 | void* memstack_alloc(memstack*, size_t bytes); | 50 | void* memstack_alloc(memstack*, size_t bytes); |
42 | 51 | ||
52 | /// Allocate a new aligned block. | ||
53 | /// | ||
54 | /// An alignment of 0 is allowed for convenience and has the same effect as 1. | ||
55 | /// | ||
56 | /// Has the same properties as memstack_alloc(). | ||
57 | void* memstack_alloc_aligned(memstack*, size_t bytes, size_t alignment); | ||
58 | |||
43 | /// Return the stack's used size in bytes. | 59 | /// Return the stack's used size in bytes. |
44 | size_t memstack_size(const memstack*); | 60 | size_t memstack_size(const memstack*); |
45 | 61 | ||