be clear on which allocator this is

This commit is contained in:
Emil Lerch 2025-12-19 15:41:26 -08:00
parent 8b51be05af
commit 50f8889e6e
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -87,7 +87,6 @@ fn handleWeatherInternal(
res: *httpz.Response, res: *httpz.Response,
location_query: []const u8, location_query: []const u8,
) !void { ) !void {
const allocator = req.arena;
// Resolve location // Resolve location
const location = if (location_query.len == 0) const location = if (location_query.len == 0)
@ -107,9 +106,10 @@ fn handleWeatherInternal(
}, },
} }
}; };
const req_alloc = req.arena;
// Fetch weather using coordinates // Fetch weather using coordinates
const weather = opts.provider.fetch(allocator, location.coords) catch |err| { const weather = opts.provider.fetch(req_alloc, location.coords) catch |err| {
switch (err) { switch (err) {
error.LocationNotFound => { error.LocationNotFound => {
res.status = 404; res.status = 404;
@ -126,10 +126,10 @@ fn handleWeatherInternal(
defer weather.deinit(); defer weather.deinit();
const query_string = req.url.query; const query_string = req.url.query;
const params = try QueryParams.parse(allocator, query_string); const params = try QueryParams.parse(req_alloc, query_string);
defer { defer {
if (params.format) |f| allocator.free(f); if (params.format) |f| req_alloc.free(f);
if (params.lang) |l| allocator.free(l); if (params.lang) |l| req_alloc.free(l);
} }
// Determine if imperial units should be used // Determine if imperial units should be used
@ -155,15 +155,15 @@ fn handleWeatherInternal(
const output = if (params.format) |fmt| blk: { const output = if (params.format) |fmt| blk: {
if (std.mem.eql(u8, fmt, "j1")) { if (std.mem.eql(u8, fmt, "j1")) {
res.content_type = .JSON; res.content_type = .JSON;
break :blk try json.render(allocator, weather); break :blk try json.render(req_alloc, weather);
} else if (std.mem.eql(u8, fmt, "v2")) { } else if (std.mem.eql(u8, fmt, "v2")) {
break :blk try v2.render(allocator, weather, use_imperial); break :blk try v2.render(req_alloc, weather, use_imperial);
} else if (std.mem.startsWith(u8, fmt, "%")) { } else if (std.mem.startsWith(u8, fmt, "%")) {
break :blk try custom.render(allocator, weather, fmt, use_imperial); break :blk try custom.render(req_alloc, weather, fmt, use_imperial);
} else { } else {
break :blk try line.render(allocator, weather, fmt, use_imperial); break :blk try line.render(req_alloc, weather, fmt, use_imperial);
} }
} else try ansi.render(allocator, weather, .{ .use_imperial = use_imperial }); } else try ansi.render(req_alloc, weather, .{ .use_imperial = use_imperial });
if (res.content_type != .JSON) { if (res.content_type != .JSON) {
res.content_type = .TEXT; res.content_type = .TEXT;