authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 19:30:41-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 19:30:41-05:00
logf8a2dec243d9bbfed8cd21528ccd93c4f4b9163e
treedf56bb2bc488e66c75a31068febac4eb8fd4b454
parent6b7e1085e38878419547ea74f0ce7259636b80b8
signaturelock-open Commit is signed but in an unrecognized format.

docs: update references to wasm_allocator


2 files changed, 5 insertions(+), 7 deletions(-)

doc/langref.html.in+4-6
......@@ -9324,8 +9324,6 @@ fn concat(allocator: *Allocator, a: []const u8, b: []const u8) ![]u8 {
93249324 </li>
93259325 <li>Are you linking libc? In this case, {#syntax#}std.heap.c_allocator{#endsyntax#} is likely
93269326 the right choice, at least for your main allocator.</li>
9327 <li>Are you building for WebAssembly? In this case, {#syntax#}std.heap.wasm_allocator{#endsyntax#} is likely
9328 the right choice for your main allocator as it uses WebAssembly's memory instructions.</li>
93299327 <li>
93309328 Is the maximum number of bytes that you will need bounded by a number known at
93319329 {#link|comptime#}? In this case, use {#syntax#}std.heap.FixedBufferAllocator{#endsyntax#} or
......@@ -9841,8 +9839,7 @@ all your base are belong to us</code></pre>
98419839 {#header_close#}
98429840 {#header_close#}
98439841 {#header_open|WebAssembly#}
9844 <p>Zig supports building for WebAssembly out of the box. There is also a specialized {#syntax#}std.heap.wasm_allocator{#endsyntax#}
9845 memory allocator for WebAssembly environments.</p>
9842 <p>Zig supports building for WebAssembly out of the box.</p>
98469843 {#header_open|Freestanding#}
98479844 <p>For host environments like the web browser and nodejs, build as a library using the freestanding OS target.
98489845 Here's an example of running Zig code compiled to WebAssembly with nodejs.</p>
......@@ -9876,8 +9873,9 @@ The result is 3</code></pre>
98769873const std = @import("std");
98779874
98789875pub fn main() !void {
9879 const args = try std.process.argsAlloc(std.heap.wasm_allocator);
9880 defer std.process.argsFree(std.heap.wasm_allocator, args);
9876 // TODO a better default allocator that isn't as wasteful!
9877 const args = try std.process.argsAlloc(std.heap.page_allocator);
9878 defer std.process.argsFree(std.heap.page_allocator, args);
98819879
98829880 for (args) |arg, i| {
98839881 std.debug.warn("{}: {}\n", i, arg);
lib/std/process.zig+1-1
......@@ -79,7 +79,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
7979 // https://github.com/WebAssembly/WASI/issues/27
8080 var environ = try allocator.alloc(?[*:0]u8, environ_count + 1);
8181 defer allocator.free(environ);
82 var environ_buf = try std.heap.wasm_allocator.alloc(u8, environ_buf_size);
82 var environ_buf = try std.heap.page_allocator.alloc(u8, environ_buf_size);
8383 defer allocator.free(environ_buf);
8484
8585 const environ_get_ret = os.wasi.environ_get(environ.ptr, environ_buf.ptr);