diff options
Diffstat (limited to 'src/proto/copy_x_response.zig')
-rw-r--r-- | src/proto/copy_x_response.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/proto/copy_x_response.zig b/src/proto/copy_x_response.zig index 9d1b26c..a4370a7 100644 --- a/src/proto/copy_x_response.zig +++ b/src/proto/copy_x_response.zig @@ -13,8 +13,9 @@ pub fn CopyXResponse(comptime tag: u8) type { overall_format_code: u8, format_codes: []const FormatCode, // owned - pub fn read(a: std.mem.Allocator, b: []const u8) !@This() { - var fbs = std.io.fixedBufferStream(b); + pub fn read(a: std.mem.Allocator, buf: []const u8) !@This() { + defer a.free(buf); + var fbs = std.io.fixedBufferStream(buf); var reader = fbs.reader(); const overall_format_code = try reader.readIntBig(u8); const n_columns = try reader.readIntBig(u16); @@ -76,7 +77,6 @@ test "round trip" { try std.testing.expectEqual(Tag, tag); const len = try reader.readIntBig(u32); const buf = try allocator.alloc(u8, len - 4); - defer allocator.free(buf); try reader.readNoEof(buf); var sm2 = try CopyInResponse.read(allocator, buf); defer sm2.deinit(allocator); |