@@ -56,6 +56,26 @@ void wpMemAllocatorFree(const WpAllocator *allocator, void **ptr, u64 size) {
|
||||
allocator->free(ptr, size, allocator->obj);
|
||||
}
|
||||
|
||||
void wpMemAllocatorTempBegin(const WpAllocator *allocator) {
|
||||
wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
|
||||
|
||||
if (!wpMemAllocatorOpSupported(allocator, WP_MEM_OP_TEMP_BEGIN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
allocator->temp_begin(allocator->obj);
|
||||
}
|
||||
|
||||
void wpMemAllocatorTempEnd(const WpAllocator *allocator) {
|
||||
wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
|
||||
|
||||
if (!wpMemAllocatorOpSupported(allocator, WP_MEM_OP_TEMP_END)) {
|
||||
return;
|
||||
}
|
||||
|
||||
allocator->temp_end(allocator->obj);
|
||||
}
|
||||
|
||||
b8 wpMemAllocatorOpSupported(const WpAllocator *allocator, WpMemOp op) {
|
||||
wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
|
||||
|
||||
@@ -70,6 +90,10 @@ b8 wpMemAllocatorOpSupported(const WpAllocator *allocator, WpMemOp op) {
|
||||
return allocator->realloc_aligned != NULL;
|
||||
case WP_MEM_OP_FREE:
|
||||
return allocator->free != NULL;
|
||||
case WP_MEM_OP_TEMP_BEGIN:
|
||||
return allocator->temp_begin != NULL;
|
||||
case WP_MEM_OP_TEMP_END:
|
||||
return allocator->temp_end != NULL;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user