AllocatorRemap_dyn
Description
Resize an allocation, allowing relocation. May return a new pointer that differs from ptr. Equivalent to C’s realloc minus the C99-style NULL-on-shrink-failure convention: 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.c:120:
}
void *AllocatorRemap_dyn(Allocator *self, void *ptr, size new_size) {
ValidateAllocator(self);- In
Allocator.c:161:
return ptr;
}
return AllocatorRemap_dyn(self, ptr, new_size);
}- In
Allocator.h:434:
///
#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)( \
(Allocator *)(self), \
(ptr), \
Last updated on