| ... | @@ -315,14 +315,14 @@ pub fn free(self: Allocator, memory: anytype) void { | ... | @@ -315,14 +315,14 @@ pub fn free(self: Allocator, memory: anytype) void { |
| 315 | } | 315 | } |
| 316 | | 316 | |
| 317 | /// Copies `m` to newly allocated memory. Caller owns the memory. | 317 | /// Copies `m` to newly allocated memory. Caller owns the memory. |
| 318 | pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) ![]T { | 318 | pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T { |
| 319 | const new_buf = try allocator.alloc(T, m.len); | 319 | const new_buf = try allocator.alloc(T, m.len); |
| 320 | @memcpy(new_buf, m); | 320 | @memcpy(new_buf, m); |
| 321 | return new_buf; | 321 | return new_buf; |
| 322 | } | 322 | } |
| 323 | | 323 | |
| 324 | /// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory. | 324 | /// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory. |
| 325 | pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) ![:0]T { | 325 | pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T { |
| 326 | const new_buf = try allocator.alloc(T, m.len + 1); | 326 | const new_buf = try allocator.alloc(T, m.len + 1); |
| 327 | @memcpy(new_buf[0..m.len], m); | 327 | @memcpy(new_buf[0..m.len], m); |
| 328 | new_buf[m.len] = 0; | 328 | new_buf[m.len] = 0; |