Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Function

realloc

Public Function
std.mem.Allocator.realloc
pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!Slice(AbsorbSentinel(@TypeOf(old_mem)))

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:

  • remap which returns null when the Allocator implementation cannot do the realloc more efficiently than the caller
  • resize which returns false when the Allocator implementation cannot change the size without relocating the allocation.

Params

Errors

OutOfMemory

File

mem/Allocator.zig:402
402
403
404
pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!Slice(AbsorbSentinel(@TypeOf(old_mem))) {
    return self.reallocAdvanced(old_mem, new_n, @returnAddress());
}