From cf3a4e763831dd7e0845fef4f209f5c780eda375 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Wed, 13 Dec 2023 08:53:06 +0100 Subject: Remove the default allocator from `ParseOptions` fixes #111 --- example/simple.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'example/simple.zig') diff --git a/example/simple.zig b/example/simple.zig index 429f095..a7207c7 100644 --- a/example/simple.zig +++ b/example/simple.zig @@ -5,6 +5,9 @@ const debug = std.debug; const io = std.io; pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + // First we specify what parameters our program can take. // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)` const params = comptime clap.parseParamsComptime( @@ -21,6 +24,7 @@ pub fn main() !void { var diag = clap.Diagnostic{}; var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ .diagnostic = &diag, + .allocator = gpa.allocator(), }) catch |err| { // Report useful error and exit diag.report(io.getStdErr().writer(), err) catch {}; -- cgit v1.2.3