diff options
-rw-r--r-- | src/main.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig index 9a0b8a4..dd6abd7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,6 +1,11 @@ const is_debug = builtin.mode == .Debug; const base64Enc = std.base64.Base64Encoder.init(std.base64.standard_alphabet_chars, '='); const base64Dec = std.base64.Base64Decoder.init(std.base64.standard_alphabet_chars, '='); +var dba: DebugAllocator = + if (is_debug) + DebugAllocator.init + else + @compileError("Should not use debug allocator in release mode"); /// Type tag for SaprusMessage union. /// This is the first value in the actual packet sent over the network. @@ -148,12 +153,11 @@ const SaprusMessage = union(SaprusPacketType) { }; pub fn main() !void { - var dba: ?DebugAllocator = if (comptime is_debug) DebugAllocator.init else null; - defer if (dba) |*d| { - _ = d.deinit(); + defer if (is_debug) { + _ = dba.deinit(); }; - var gpa = if (dba) |*d| d.allocator() else std.heap.smp_allocator; + var gpa = if (is_debug) dba.allocator() else std.heap.smp_allocator; const msg = SaprusMessage{ .relay = .{ |