aboutsummaryrefslogtreecommitdiff
path: root/src/proto/row_description.zig
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-09-28 20:46:10 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-09-28 20:46:10 +0100
commitc00a7cd57be154b5a770a397319c8c8ad35c98b6 (patch)
tree89ef0f7bef322574883260c8952e0f3f71fa40ff /src/proto/row_description.zig
parentd1435847fa68a548f8a2b8c61857691c6f5ac924 (diff)
downloadpgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.tar.gz
pgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.tar.bz2
pgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.tar.xz
pgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.zip
WIP
Diffstat (limited to 'src/proto/row_description.zig')
-rw-r--r--src/proto/row_description.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/proto/row_description.zig b/src/proto/row_description.zig
index ff17716..50e4cb0 100644
--- a/src/proto/row_description.zig
+++ b/src/proto/row_description.zig
@@ -74,6 +74,14 @@ pub fn write(self: RowDescription, a: std.mem.Allocator, stream_writer: anytype)
try stream_writer.writeAll(al.items);
}
+// Caller owns the result.
+pub fn clone(self: RowDescription, a: std.mem.Allocator) !RowDescription {
+ var ba = ByteArrayList.init(a);
+ errdefer ba.deinit();
+ try self.write(a, ba.writer());
+ return try RowDescription.read(a, ba.items);
+}
+
pub fn deinit(self: *RowDescription, a: std.mem.Allocator) void {
a.free(self.fields);
if (self.buf != null) a.free(self.buf.?);