Function dupeZ [src]
Copies m to newly allocated memory, with a null-terminated element. Caller owns the memory.
Prototype
pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T
Parameters
allocator: Allocator
T: type
m: []const T
Possible Errors
Source
pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T {
const new_buf = try allocator.alloc(T, m.len + 1);
@memcpy(new_buf[0..m.len], m);
new_buf[m.len] = 0;
return new_buf[0..m.len :0];
}