pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!Slice(AbsorbSentinel(@TypeOf(old_mem))) self: Allocatorold_memnew_n: usizeOutOfMemory402
403
404pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!Slice(AbsorbSentinel(@TypeOf(old_mem))) {
return self.reallocAdvanced(old_mem, new_n, @returnAddress());
}
This function requests a new size for an existing allocation, which can be larger, smaller, or the same size as the old memory allocation. The result is an array of
new_nitems of the same type as the existing allocation.If
new_nis 0, this is the same asfreeand it always succeeds.old_memmay have length zero, which makes a new allocation.This function only fails on out-of-memory conditions, unlike:
remapwhich returnsnullwhen theAllocatorimplementation cannot do the realloc more efficiently than the callerresizewhich returnsfalsewhen theAllocatorimplementation cannot change the size without relocating the allocation.