diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/message_parser.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/server/message_parser.zig b/src/server/message_parser.zig index 600741d..c91836e 100644 --- a/src/server/message_parser.zig +++ b/src/server/message_parser.zig @@ -270,7 +270,7 @@ pub const Message = union(MessageType) { // for storing the json string var connect_string_writer_allocating: std.Io.Writer.Allocating = .init(alloc); defer connect_string_writer_allocating.deinit(); - var connect_string_writer = connect_string_writer_allocating.writer; + var connect_string_writer = &connect_string_writer_allocating.writer; // for parsing the json string var connect_arena_allocator: std.heap.ArenaAllocator = .init(alloc); @@ -280,15 +280,17 @@ pub const Message = union(MessageType) { try in.discardAll(1); // throw away space // Should read the next JSON object to the fixed buffer writer. - _ = try in.streamDelimiter(&connect_string_writer, '}'); + _ = try in.streamDelimiter(connect_string_writer, '}'); try connect_string_writer.writeByte('}'); try expectStreamBytes(in, "}\r\n"); // discard '}\r\n' + const connect_str = try connect_string_writer_allocating.toOwnedSlice(); + defer alloc.free(connect_str); // TODO: should be CONNECTION allocator const res = try std.json.parseFromSliceLeaky( Connect, connect_allocator, - connect_string_writer.buffered(), + connect_str, .{ .allocate = .alloc_always }, ); |
