authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-29 21:39:08-06:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-29 22:22:01-06:00
log837877ea373d295cb30c4c1f4ebc2ff561d52a79
treeebf215270aeac272e17adaf67f00415644877c40
parent898ef82d65af9a00aadc7ed63e5e1c0bc6c52bde

Update docs to reflect new testing.allocator usage


1 files changed, 4 insertions(+), 5 deletions(-)

doc/langref.html.in+4-5
...@@ -5359,7 +5359,7 @@ const std = @import("std");...@@ -5359,7 +5359,7 @@ const std = @import("std");
5359const assert = std.debug.assert;5359const assert = std.debug.assert;
53605360
5361test "turn HashMap into a set with void" {5361test "turn HashMap into a set with void" {
5362 var map = std.HashMap(i32, void, hash_i32, eql_i32).init(std.debug.global_allocator);5362 var map = std.HashMap(i32, void, hash_i32, eql_i32).init(std.testing.allocator);
5363 defer map.deinit();5363 defer map.deinit();
53645364
5365 _ = try map.put(1, {});5365 _ = try map.put(1, {});
...@@ -9281,9 +9281,8 @@ fn concat(allocator: *Allocator, a: []const u8, b: []const u8) ![]u8 {...@@ -9281,9 +9281,8 @@ fn concat(allocator: *Allocator, a: []const u8, b: []const u8) ![]u8 {
9281 In the above example, 100 bytes of stack memory are used to initialize a9281 In the above example, 100 bytes of stack memory are used to initialize a
9282 {#syntax#}FixedBufferAllocator{#endsyntax#}, which is then passed to a function.9282 {#syntax#}FixedBufferAllocator{#endsyntax#}, which is then passed to a function.
9283 As a convenience there is a global {#syntax#}FixedBufferAllocator{#endsyntax#}9283 As a convenience there is a global {#syntax#}FixedBufferAllocator{#endsyntax#}
9284 available for quick tests at {#syntax#}std.debug.global_allocator{#endsyntax#},9284 available for quick tests at {#syntax#}std.testing.allocator{#endsyntax#},
9285 however it is deprecated and should be avoided in favor of directly using a9285 which will also do perform basic leak detection.
9286 {#syntax#}FixedBufferAllocator{#endsyntax#} as in the example above.
9287 </p>9286 </p>
9288 <p>9287 <p>
9289 Currently Zig has no general purpose allocator, but there is9288 Currently Zig has no general purpose allocator, but there is
...@@ -9341,7 +9340,7 @@ pub fn main() !void {...@@ -9341,7 +9340,7 @@ pub fn main() !void {
9341 </li>9340 </li>
9342 <li>9341 <li>
9343 Are you writing a test, and you want to make sure {#syntax#}error.OutOfMemory{#endsyntax#}9342 Are you writing a test, and you want to make sure {#syntax#}error.OutOfMemory{#endsyntax#}
9344 is handled correctly? In this case, use {#syntax#}std.debug.FailingAllocator{#endsyntax#}.9343 is handled correctly? In this case, use {#syntax#}std.testing.FailingAllocator{#endsyntax#}.
9345 </li>9344 </li>
9346 <li>9345 <li>
9347 Finally, if none of the above apply, you need a general purpose allocator. Zig does not9346 Finally, if none of the above apply, you need a general purpose allocator. Zig does not