AllocatorRemap
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)). |
old_size |
in | Previous allocation size in bytes. |
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:130:
}
void *AllocatorRemap(Allocator *self, void *ptr, size old_size, size new_size) {
ValidateAllocator(self);- In
Allocator.c:165:
return ptr;
}
return AllocatorRemap(self, ptr, old_size, new_size);
}
Last updated on