diff --git a/doc/langref.html.in b/doc/langref.html.in index f6684eb195..8c118cf3b2 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -9324,8 +9324,6 @@ fn concat(allocator: *Allocator, a: []const u8, b: []const u8) ![]u8 {
  • Are you linking libc? In this case, {#syntax#}std.heap.c_allocator{#endsyntax#} is likely the right choice, at least for your main allocator.
  • -
  • Are you building for WebAssembly? In this case, {#syntax#}std.heap.wasm_allocator{#endsyntax#} is likely - the right choice for your main allocator as it uses WebAssembly's memory instructions.
  • Is the maximum number of bytes that you will need bounded by a number known at {#link|comptime#}? In this case, use {#syntax#}std.heap.FixedBufferAllocator{#endsyntax#} or @@ -9841,8 +9839,7 @@ all your base are belong to us {#header_close#} {#header_close#} {#header_open|WebAssembly#} -

    Zig supports building for WebAssembly out of the box. There is also a specialized {#syntax#}std.heap.wasm_allocator{#endsyntax#} - memory allocator for WebAssembly environments.

    +

    Zig supports building for WebAssembly out of the box.

    {#header_open|Freestanding#}

    For host environments like the web browser and nodejs, build as a library using the freestanding OS target. Here's an example of running Zig code compiled to WebAssembly with nodejs.

    @@ -9876,8 +9873,9 @@ The result is 3 const std = @import("std"); pub fn main() !void { - const args = try std.process.argsAlloc(std.heap.wasm_allocator); - defer std.process.argsFree(std.heap.wasm_allocator, args); + // 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); for (args) |arg, i| { std.debug.warn("{}: {}\n", i, arg); diff --git a/lib/std/process.zig b/lib/std/process.zig index 9880108465..e432be213f 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -79,7 +79,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { // https://github.com/WebAssembly/WASI/issues/27 var environ = try allocator.alloc(?[*:0]u8, environ_count + 1); defer allocator.free(environ); - var environ_buf = try std.heap.wasm_allocator.alloc(u8, environ_buf_size); + var environ_buf = try std.heap.page_allocator.alloc(u8, environ_buf_size); defer allocator.free(environ_buf); const environ_get_ret = os.wasi.environ_get(environ.ptr, environ_buf.ptr);