zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f8a2dec243d9bbfed8cd21528ccd93c4f4b9163e (tree)
parent 6b7e1085e38878419547ea74f0ce7259636b80b8
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon, 25 Nov 2019 19:30:41 -0500

docs: update references to wasm_allocator

Diffstat:
Mdoc/langref.html.in | 10++++------
Mlib/std/process.zig | 2+-
2 files changed, 5 insertions(+), 7 deletions(-)

diff --git 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 { </li> <li>Are you linking libc? In this case, {#syntax#}std.heap.c_allocator{#endsyntax#} is likely the right choice, at least for your main allocator.</li> - <li>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.</li> <li> 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</code></pre> {#header_close#} {#header_close#} {#header_open|WebAssembly#} - <p>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.</p> + <p>Zig supports building for WebAssembly out of the box.</p> {#header_open|Freestanding#} <p>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.</p> @@ -9876,8 +9873,9 @@ The result is 3</code></pre> 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 @@ -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);