diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-02-09 18:27:50 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-02-09 18:27:50 -0500 |
| commit | a2bd9f8912ade5149855dc6e2371aaae49093660 (patch) | |
| tree | 04dab23f1d6d730b5266506422daf820124fa139 /std/cstr.zig | |
| parent | e7bf8f3f04efc280a76a3a38b4e6d470d279e41a (diff) | |
| download | zig-a2bd9f8912ade5149855dc6e2371aaae49093660.tar.gz zig-a2bd9f8912ade5149855dc6e2371aaae49093660.zip | |
std lib: modify allocator idiom
Before we accepted a nullable allocator for some stuff like
opening files. Now we require an allocator.
Use the mem.FixedBufferAllocator pattern if a bound on the amount
to allocate is known.
This also establishes the pattern that usually an allocator is the
first argument to a function (possibly after "self").
fix docs for std.cstr.addNullByte
self hosted compiler:
* only build docs when explicitly asked to
* clean up main
* stub out zig fmt
Diffstat (limited to 'std/cstr.zig')
| -rw-r--r-- | std/cstr.zig | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/std/cstr.zig b/std/cstr.zig index 86d59b11dd..f905b57c91 100644 --- a/std/cstr.zig +++ b/std/cstr.zig @@ -39,8 +39,7 @@ fn testCStrFnsImpl() void { assert(len(c"123456789") == 9); } -/// Returns a mutable slice with exactly the same size which is guaranteed to -/// have a null byte after it. +/// Returns a mutable slice with 1 more byte of length which is a null byte. /// Caller owns the returned memory. pub fn addNullByte(allocator: &mem.Allocator, slice: []const u8) ![]u8 { const result = try allocator.alloc(u8, slice.len + 1); |
