From c00a7cd57be154b5a770a397319c8c8ad35c98b6 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Thu, 28 Sep 2023 20:46:10 +0100 Subject: WIP --- src/proto/command_complete.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/proto/command_complete.zig') diff --git a/src/proto/command_complete.zig b/src/proto/command_complete.zig index ed8e052..f9a9e26 100644 --- a/src/proto/command_complete.zig +++ b/src/proto/command_complete.zig @@ -30,6 +30,13 @@ pub fn deinit(self: *CommandComplete, a: std.mem.Allocator) void { if (self.buf != null) a.free(self.buf.?); } +pub fn clone(self: CommandComplete, a: std.mem.Allocator) !CommandComplete { + var ba = ByteArrayList.init(a); + errdefer ba.deinit(); + try self.write(a, ba.writer()); + return try CommandComplete.read(a, ba.items); +} + test "round trip" { const allocator = std.testing.allocator; var sm = CommandComplete{ -- cgit v1.2.3-ZIG