pub fn dupeSentinel( allocator: Allocator, comptime T: type, m: []const T, comptime sentinel: T, ) Error![:sentinel]T
Copies m to newly allocated memory, with a null-terminated element. Caller owns the memory.
m
allocator: Allocator
T: type
m: []const T
sentinel: T
OutOfMemory
467 468 469 470 471 472 473 474 475 476 477
pub fn dupeSentinel( allocator: Allocator, comptime T: type, m: []const T, comptime sentinel: T, ) Error![:sentinel]T { const new_buf = try allocator.alloc(T, m.len + 1); @memcpy(new_buf[0..m.len], m); new_buf[m.len] = sentinel; return new_buf[0..m.len :sentinel]; }
Copies
mto newly allocated memory, with a null-terminated element. Caller owns the memory.