Add static, runtime and debug assert utilities
This commit is contained in:
@@ -2,27 +2,27 @@
|
||||
|
||||
#include "mem_allocator.h"
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/assert/assert.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size) {
|
||||
assert(allocator != NULL && (allocator->alloc) != NULL);
|
||||
wapp_debug_assert(allocator != NULL && (allocator->alloc) != NULL, "`allocator` and `allocator->alloc` should not be NULL");
|
||||
return allocator->alloc(size, allocator->obj);
|
||||
}
|
||||
|
||||
void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment) {
|
||||
assert(allocator != NULL && (allocator->alloc_aligned) != NULL);
|
||||
wapp_debug_assert(allocator != NULL && (allocator->alloc_aligned) != NULL, "`allocator` and `allocator->alloc_aligned` should not be NULL");
|
||||
return allocator->alloc_aligned(size, alignment, allocator->obj);
|
||||
}
|
||||
|
||||
void *wapp_mem_allocator_realloc(const Allocator *allocator, void *ptr, u64 old_size, u64 new_size) {
|
||||
assert(allocator != NULL && (allocator->realloc) != NULL);
|
||||
wapp_debug_assert(allocator != NULL && (allocator->realloc) != NULL, "`allocator` and `allocator->realloc` should not be NULL");
|
||||
return allocator->realloc(ptr, old_size, new_size, allocator->obj);
|
||||
}
|
||||
|
||||
void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr, u64 old_size,
|
||||
u64 new_size, u64 alignment) {
|
||||
assert(allocator != NULL && (allocator->realloc_aligned) != NULL);
|
||||
wapp_debug_assert(allocator != NULL && (allocator->realloc_aligned) != NULL, "`allocator` and `allocator->realloc_aligned` should not be NULL");
|
||||
return allocator->realloc_aligned(ptr, old_size, new_size, alignment, allocator->obj);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user