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.

dupe

Copies m to newly allocated memory. Caller owns the memory.

Allocator.dupe
pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T

File

lib/std/mem/Allocator.zig:459

Code

pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T {
    const new_buf = try allocator.alloc(T, m.len);
    @memcpy(new_buf, m);
    return new_buf;
}