| author | |
| committer | |
| log | 823d1e70876d79dfae9dde0496e7cf293995c44a |
| tree | e39e625d4e934b87d8b48770eff9dd5d720d0617 |
| parent | 4a701490d4c403938e093c6bfb32b8723eb01786 |
2 files changed, 11 insertions(+), 4 deletions(-)
lib/std/heap.zig+10| ... | ... | @@ -224,6 +224,16 @@ else |
| 224 | 224 | .vtable = &PageAllocator.vtable, |
| 225 | 225 | }; |
| 226 | 226 | |
| 227 | /// This allocator is fast, small, and specific to WebAssembly. In the future, | |
| 228 | /// this will be the implementation automatically selected by | |
| 229 | /// `GeneralPurposeAllocator` when compiling in `ReleaseSmall` mode for wasm32 | |
| 230 | /// and wasm64 architectures. | |
| 231 | /// Until then, it is available here to play with. | |
| 232 | pub const wasm_allocator = Allocator{ | |
| 233 | .ptr = undefined, | |
| 234 | .vtable = &std.heap.WasmAllocator.vtable, | |
| 235 | }; | |
| 236 | ||
| 227 | 237 | /// Verifies that the adjusted length will still map to the full length |
| 228 | 238 | pub fn alignPageAllocLen(full_len: usize, len: usize) usize { |
| 229 | 239 | const aligned_len = mem.alignAllocLen(full_len, len); |
src/main.zig+1-4| ... | ... | @@ -155,10 +155,7 @@ pub fn main() anyerror!void { |
| 155 | 155 | const use_gpa = (build_options.force_gpa or !builtin.link_libc) and builtin.os.tag != .wasi; |
| 156 | 156 | const gpa = gpa: { |
| 157 | 157 | if (builtin.os.tag == .wasi) { |
| 158 | break :gpa Allocator{ | |
| 159 | .ptr = undefined, | |
| 160 | .vtable = &std.heap.WasmAllocator.vtable, | |
| 161 | }; | |
| 158 | break :gpa std.heap.wasm_allocator; | |
| 162 | 159 | } |
| 163 | 160 | if (use_gpa) { |
| 164 | 161 | break :gpa general_purpose_allocator.allocator(); |