summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Client.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Client.zig b/src/Client.zig
index af78d39..57af48c 100644
--- a/src/Client.zig
+++ b/src/Client.zig
@@ -85,7 +85,7 @@ pub fn sendInitialConnection(payload: []const u8, initial_port: u16, allocator:
base64Enc.calcSize(payload.len),
),
);
- defer allocator.free(msg_bytes);
+
const msg: *SaprusMessage = .init(.connection, msg_bytes);
const connection = (try msg.getSaprusTypePayload()).connection;
@@ -120,8 +120,9 @@ pub fn connect(payload: []const u8, allocator: Allocator) !?SaprusConnection {
try sock.bind(bind_addr);
const msg = try sendInitialConnection(payload, initial_port, allocator);
+ defer allocator.free(msg.asBytes());
- var response_buf: [4096]u8 align(4) = @splat(0);
+ var response_buf: [4096]u8 align(@alignOf(SaprusMessage)) = undefined;
_ = try sock.receive(&response_buf); // Ignore message that I sent.
const len = try sock.receive(&response_buf);