diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-04-04 21:14:41 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-04-06 13:08:09 -0400 |
commit | 58ed9048daecec1d150c93c4b0b63af30e3d5ec9 (patch) | |
tree | 62cb853e071bdbafc4b6072feb7c593bb721a4e0 /src/main.zig | |
parent | 88b2734886b9740293eafe75899d17fd5be32c68 (diff) |
GREATLY improve clarity
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index dd6abd7..004c83b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,6 +1,9 @@ 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, '='); + +/// This creates a debug allocator that can only be referenced in debug mode. +/// You should check for is_debug around every reference to dba. var dba: DebugAllocator = if (is_debug) DebugAllocator.init @@ -143,7 +146,9 @@ const SaprusMessage = union(SaprusPacketType) { var s = std.io.fixedBufferStream(bytes); const r = s.reader(); - switch (@as(SaprusPacketType, @enumFromInt(try r.readInt(u16, .big)))) { + const packet_type = @as(SaprusPacketType, @enumFromInt(try r.readInt(u16, .big))); + + switch (packet_type) { .relay => return fromBytesAux(.relay, Relay.Header, r, allocator), .connection => return fromBytesAux(.connection, Connection.Header, r, allocator), .file_transfer => return SaprusError.NotImplementedSaprusType, |