authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-29 00:24:17-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-29 00:24:17-07:00
log9d0da1612e6abf4a05fd6461231f727238d71759
tree25f250a80b6947ec4f452c4e50d519ba294a00b1
parented06a78f35e7281289249b0d0c119bd64845dd51

langref: use general purpose allocator in the wasi example


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

doc/langref.html.in+5-4
...@@ -9889,12 +9889,13 @@ The result is 3</code></pre>...@@ -9889,12 +9889,13 @@ The result is 3</code></pre>
9889const std = @import("std");9889const std = @import("std");
98909890
9891pub fn main() !void {9891pub fn main() !void {
9892 // TODO a better default allocator that isn't as wasteful!9892 var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
9893 const args = try std.process.argsAlloc(std.heap.page_allocator);9893 const gpa = &general_purpose_allocator.allocator;
9894 defer std.process.argsFree(std.heap.page_allocator, args);9894 const args = try std.process.argsAlloc(gpa);
9895 defer std.process.argsFree(gpa, args);
98959896
9896 for (args) |arg, i| {9897 for (args) |arg, i| {
9897 std.debug.print("{}: {}\n", .{i, arg});9898 std.debug.print("{}: {}\n", .{ i, arg });
9898 }9899 }
9899}9900}
9900 {#code_end#}9901 {#code_end#}