| ... | @@ -9357,9 +9357,17 @@ pub fn main() !void { | ... | @@ -9357,9 +9357,17 @@ pub fn main() !void { |
| 9357 | is handled correctly? In this case, use {#syntax#}std.testing.FailingAllocator{#endsyntax#}. | 9357 | is handled correctly? In this case, use {#syntax#}std.testing.FailingAllocator{#endsyntax#}. |
| 9358 | </li> | 9358 | </li> |
| 9359 | <li> | 9359 | <li> |
| 9360 | Finally, if none of the above apply, you need a general purpose allocator. Zig does not | 9360 | Are you writing a test? In this case, use {#syntax#}std.testing.allocator{#endsyntax#}. |
| 9361 | yet have a general purpose allocator in the standard library, | 9361 | </li> |
| 9362 | <a href="https://github.com/andrewrk/zig-general-purpose-allocator/">but one is being actively developed</a>. | 9362 | <li> |
| | 9363 | Finally, if none of the above apply, you need a general purpose allocator. |
| | 9364 | Zig's general purpose allocator is available as a function that takes a {#link|comptime#} |
| | 9365 | {#link|struct#} of configuration options and returns a type. |
| | 9366 | Generally, you will set up one {#syntax#}std.heap.GeneralPurposeAllocator#{endsyntax#} in |
| | 9367 | your main function, and then pass it or sub-allocators around to various parts of your |
| | 9368 | application. |
| | 9369 | </li> |
| | 9370 | <li> |
| 9363 | You can also consider {#link|Implementing an Allocator#}. | 9371 | You can also consider {#link|Implementing an Allocator#}. |
| 9364 | </li> | 9372 | </li> |
| 9365 | </ol> | 9373 | </ol> |