aboutsummaryrefslogtreecommitdiff
path: root/src/proto/data_row.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/proto/data_row.zig')
-rw-r--r--src/proto/data_row.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/proto/data_row.zig b/src/proto/data_row.zig
index 43c4526..6bfcc1d 100644
--- a/src/proto/data_row.zig
+++ b/src/proto/data_row.zig
@@ -54,6 +54,14 @@ pub fn deinit(self: *DataRow, a: std.mem.Allocator) void {
a.free(self.columns);
}
+// Caller owns the new DataRow.
+pub fn clone(self: DataRow, a: std.mem.Allocator) !DataRow {
+ var ba = ByteArrayList.init(a);
+ errdefer ba.deinit();
+ try self.write(a, ba.writer());
+ return try DataRow.read(a, ba.items);
+}
+
test "round trip" {
const allocator = std.testing.allocator;
const columns = try allocator.alloc([]const u8, 3);