aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-29 00:24:17 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-29 00:24:17 -0700
commit9d0da1612e6abf4a05fd6461231f727238d71759 (patch)
tree25f250a80b6947ec4f452c4e50d519ba294a00b1 /doc
parented06a78f35e7281289249b0d0c119bd64845dd51 (diff)
downloadzig-9d0da1612e6abf4a05fd6461231f727238d71759.tar.gz
zig-9d0da1612e6abf4a05fd6461231f727238d71759.zip
langref: use general purpose allocator in the wasi example
Diffstat (limited to 'doc')
-rw-r--r--doc/langref.html.in9
1 files changed, 5 insertions, 4 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in
index 320b10bbe5..870764f054 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -9889,12 +9889,13 @@ The result is 3</code></pre>
const std = @import("std");
pub fn main() !void {
- // TODO a better default allocator that isn't as wasteful!
- const args = try std.process.argsAlloc(std.heap.page_allocator);
- defer std.process.argsFree(std.heap.page_allocator, args);
+ var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
+ const gpa = &general_purpose_allocator.allocator;
+ const args = try std.process.argsAlloc(gpa);
+ defer std.process.argsFree(gpa, args);
for (args) |arg, i| {
- std.debug.print("{}: {}\n", .{i, arg});
+ std.debug.print("{}: {}\n", .{ i, arg });
}
}
{#code_end#}