mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 03:34:48 +00:00
Fix connect parsing
This commit is contained in:
@@ -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 },
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user