From 50f8889e6eb17bf3e6f5acf3e8460f0ac2b02590 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Fri, 19 Dec 2025 15:41:26 -0800 Subject: [PATCH] be clear on which allocator this is --- src/http/handler.zig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/http/handler.zig b/src/http/handler.zig index 245e7e4..b1d7683 100644 --- a/src/http/handler.zig +++ b/src/http/handler.zig @@ -87,7 +87,6 @@ fn handleWeatherInternal( res: *httpz.Response, location_query: []const u8, ) !void { - const allocator = req.arena; // Resolve location const location = if (location_query.len == 0) @@ -107,9 +106,10 @@ fn handleWeatherInternal( }, } }; + const req_alloc = req.arena; // 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) { error.LocationNotFound => { res.status = 404; @@ -126,10 +126,10 @@ fn handleWeatherInternal( defer weather.deinit(); const query_string = req.url.query; - const params = try QueryParams.parse(allocator, query_string); + const params = try QueryParams.parse(req_alloc, query_string); defer { - if (params.format) |f| allocator.free(f); - if (params.lang) |l| allocator.free(l); + if (params.format) |f| req_alloc.free(f); + if (params.lang) |l| req_alloc.free(l); } // Determine if imperial units should be used @@ -155,15 +155,15 @@ fn handleWeatherInternal( const output = if (params.format) |fmt| blk: { if (std.mem.eql(u8, fmt, "j1")) { 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")) { - 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, "%")) { - break :blk try custom.render(allocator, weather, fmt, use_imperial); + break :blk try custom.render(req_alloc, weather, fmt, use_imperial); } 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) { res.content_type = .TEXT;