From 72b5ceed66005f03933a4e5bbd0eda08378b0fd0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 8 Aug 2020 02:15:34 -0700 Subject: update langref in light of new general purpose allocator --- doc/langref.html.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/langref.html.in b/doc/langref.html.in index 941c2cc1a6..dbdeb0fb42 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -9357,9 +9357,17 @@ pub fn main() !void { is handled correctly? In this case, use {#syntax#}std.testing.FailingAllocator{#endsyntax#}.
  • - Finally, if none of the above apply, you need a general purpose allocator. Zig does not - yet have a general purpose allocator in the standard library, - but one is being actively developed. + Are you writing a test? In this case, use {#syntax#}std.testing.allocator{#endsyntax#}. +
  • +
  • + Finally, if none of the above apply, you need a general purpose allocator. + Zig's general purpose allocator is available as a function that takes a {#link|comptime#} + {#link|struct#} of configuration options and returns a type. + Generally, you will set up one {#syntax#}std.heap.GeneralPurposeAllocator#{endsyntax#} in + your main function, and then pass it or sub-allocators around to various parts of your + application. +
  • +
  • You can also consider {#link|Implementing an Allocator#}.
  • -- cgit v1.2.3