mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 19:54:48 +00:00
Much better cleanup, still fast B)
This commit is contained in:
@@ -137,6 +137,16 @@ pub const Message = union(MessageType) {
|
||||
alloc.free(self.payload);
|
||||
if (self.reply_to) |r| alloc.free(r);
|
||||
}
|
||||
|
||||
pub fn toMsg(self: Pub, alloc: std.mem.Allocator, sid: []const u8) !Msg {
|
||||
const res: Msg = .{
|
||||
.subject = self.subject,
|
||||
.sid = sid,
|
||||
.reply_to = self.reply_to,
|
||||
.payload = self.payload,
|
||||
};
|
||||
return res.dupe(alloc);
|
||||
}
|
||||
};
|
||||
pub const Sub = struct {
|
||||
/// The subject name to subscribe to.
|
||||
@@ -177,7 +187,7 @@ pub const Message = union(MessageType) {
|
||||
errdefer alloc.free(res.subject);
|
||||
res.sid = try alloc.dupe(u8, self.sid);
|
||||
errdefer alloc.free(res.sid);
|
||||
res.reply_to = if (self.reply_to) |r| alloc.dupe(u8, r) else null;
|
||||
res.reply_to = if (self.reply_to) |r| try alloc.dupe(u8, r) else null;
|
||||
errdefer if (res.reply_to) |r| alloc.free(r);
|
||||
res.payload = try alloc.dupe(u8, self.payload);
|
||||
errdefer alloc.free(res.payload);
|
||||
|
||||
Reference in New Issue
Block a user