mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
server: let the caller of sendSync free the string
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -207,6 +207,7 @@ pub fn sendEvent(
|
||||
const resp = Resp{ .method = name, .params = params, .sessionId = sessionID };
|
||||
|
||||
const event_msg = try stringify(alloc, resp);
|
||||
defer alloc.free(event_msg);
|
||||
std.log.debug("event {s}", .{event_msg});
|
||||
try server.sendSync(ctx, event_msg);
|
||||
}
|
||||
|
||||
@@ -269,6 +269,7 @@ fn navigate(
|
||||
.loaderId = ctx.state.loaderID,
|
||||
};
|
||||
const res = try result(alloc, id orelse msg.id.?, Resp, resp, msg.sessionID);
|
||||
defer alloc.free(res);
|
||||
std.log.debug("res {s}", .{res});
|
||||
try server.sendSync(ctx, res);
|
||||
|
||||
|
||||
@@ -308,6 +308,7 @@ fn closeTarget(
|
||||
success: bool = true,
|
||||
};
|
||||
const res = try result(alloc, id orelse msg.id.?, Resp, Resp{}, null);
|
||||
defer alloc.free(res);
|
||||
try server.sendSync(ctx, res);
|
||||
|
||||
// Inspector.detached event
|
||||
|
||||
@@ -214,7 +214,6 @@ pub fn sendAsync(ctx: *Cmd, msg: []const u8) !void {
|
||||
}
|
||||
|
||||
pub fn sendSync(ctx: *Cmd, msg: []const u8) !void {
|
||||
defer ctx.alloc().free(msg);
|
||||
const s = try std.posix.write(ctx.socket, msg);
|
||||
std.log.debug("send sync {d} bytes", .{s});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user