Skip to content

Commit 0310192

Browse files
committed
dom: assume we are using an arena for cookie
1 parent c88bc65 commit 0310192

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/html/document.zig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,14 @@ pub const HTMLDocument = struct {
8484
}
8585
}
8686

87-
pub fn get_cookie(_: *parser.DocumentHTML, allocator: std.mem.Allocator, userctx: UserContext) ![]const u8 {
87+
pub fn get_cookie(_: *parser.DocumentHTML, arena: std.mem.Allocator, userctx: UserContext) ![]const u8 {
8888
var buf: std.ArrayListUnmanaged(u8) = .{};
89-
defer buf.deinit(allocator);
90-
try userctx.cookie_jar.forRequest(&userctx.url.uri, buf.writer(allocator), .{ .navigation = true });
91-
return buf.toOwnedSlice(allocator);
89+
try userctx.cookie_jar.forRequest(&userctx.url.uri, buf.writer(arena), .{ .navigation = true });
90+
return buf.items;
9291
}
9392

94-
pub fn set_cookie(_: *parser.DocumentHTML, allocator: std.mem.Allocator, userctx: UserContext, cookie_str: []const u8) ![]const u8 {
95-
const c = try Cookie.parse(allocator, &userctx.url.uri, cookie_str);
93+
pub fn set_cookie(_: *parser.DocumentHTML, arena: std.mem.Allocator, userctx: UserContext, cookie_str: []const u8) ![]const u8 {
94+
const c = try Cookie.parse(arena, &userctx.url.uri, cookie_str);
9695
try userctx.cookie_jar.add(c, std.time.timestamp());
9796

9897
return cookie_str;

0 commit comments

Comments
 (0)