@@ 19,12 19,13 @@ const std = @import("std");
pub fn main() !void {
var input = std.io.fixedBufferStream("5:hello,6:world!,");
var parser = netstring.netStringParser(input.reader());
+ var buf: [1024]u8 = undefined;
// Repeat while the parser can find another netstring
while (try parser.next()) |reader| {
// Read the current netstring and print it
- const msg = try reader.readAllAlloc(std.heap.page_allocator, 4096);
- std.debug.print("{s}\n", .{msg});
+ const bytes = try reader.readAll(&buf);
+ std.debug.print("{s}\n", .{buf[0..bytes]});
}
}
```