diff options
Diffstat (limited to 'BumpAlloc.c')
| -rw-r--r-- | BumpAlloc.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/BumpAlloc.c b/BumpAlloc.c index 09af8fa..e162081 100644 --- a/BumpAlloc.c +++ b/BumpAlloc.c @@ -14,7 +14,7 @@ top_size(struct BumpAlloc* b) { return (usize*)(b->memory + b->top); } -static int +static inline int bump_resizeable(struct BumpAlloc *b, void *ptr) { if (NULL == b) return 0; @@ -48,6 +48,9 @@ bump_free(MemoryManager mm, void **ptr) { Result bump_destroy(MemoryManager *mm) { + if (NULL == mm) + return R_NullArgument; + if (NULL == mm->priv) return R_Uninitialized; @@ -56,7 +59,7 @@ bump_destroy(MemoryManager *mm) { if (NULL == b.memory) { free(mm->priv); mm->priv = NULL; - return R_Uninitialized; + return R_InvalidArgument; } free(b.memory); @@ -67,13 +70,13 @@ bump_destroy(MemoryManager *mm) { } Result -bump_alloc(MemoryManager mm, void** ptr, usize size) { - if (NULL == mm.priv) - return R_Uninitialized; - +bump_alloc(MemoryManager mm, void **ptr, usize size) { if (0 == size || NULL == ptr) return R_NullArgument; + if (NULL == mm.priv) + return R_Uninitialized; + struct BumpAlloc *b = (struct BumpAlloc*)mm.priv; if (size + b->top + sizeof(usize) > b->size) |
