Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

realloc

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_n items of the same type as the existing allocation.

If new_n is 0, this is the same as free and it always succeeds.

old_mem may have length zero, which makes a new allocation.

This function only fails on out-of-memory conditions, unlike:

Allocator.realloc
pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!@TypeOf(old_mem)

File

lib/std/mem/Allocator.zig:402

Code

pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!@TypeOf(old_mem) {
    return self.reallocAdvanced(old_mem, new_n, @returnAddress());
}