AllocatorRemap_dyn
Description
Resize an allocation, allowing relocation. May return a new pointer that differs from ptr. Behaves like a remap entry point with one extra rule: if new_size == 0 the allocation is freed and NULL returned.
Parameters
| Name | Direction | Description |
|---|---|---|
self |
in,out | Allocator base. |
ptr |
in | Existing allocation pointer, or NULL (then this behaves like AllocatorAlloc(self, new_size, 0)). |
new_size |
in | Requested new allocation size in bytes. |
Success
Returns the (possibly moved) pointer, or NULL when new_size is zero.
Failure
Returns NULL when the underlying allocator can’t satisfy the request.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Allocator.h:471:
///
#define AllocatorRemap(self, ptr, new_size) \
_Generic((self), HeapAllocator *: heap_allocator_remap, PageAllocator *: page_allocator_remap, ArenaAllocator *: arena_allocator_remap, SlabAllocator *: slab_allocator_remap, BudgetAllocator *: budget_allocator_remap, DebugAllocator *: debug_allocator_remap, Allocator *: AllocatorRemap_dyn)( \
(self), \
(ptr), \- In
Allocator.c:82:
}
void *AllocatorRemap_dyn(Allocator *self, void *ptr, size new_size) {
ValidateAllocator(self);
Last updated on