How do you hold a debug allocator, so that you can clean it up only if you need to? I am trying to do someting like this:
var dba: ?std.heap.DebugAllocator = null;
pub export fn setup() void {
std.debug.print("Starting android.", .{});
if (builtin.mode == .Debug) {
dba = std.heap.DebugAllocator(.{}){};
do_stuff(dba.allocator());
} else {
do_stuff(std.heap.smp_allocator);
}
}
I understand enougn to know that this error means that I am being retruned a function not a struct, but I don`t know exactly what the right way to fix this is:
src/main.zig:2:19: error: expected type 'type', found 'fn (comptime heap.debug_allocator.Config) type'
var dba: ?std.heap.DebugAllocator = null;
Thanks!