fix leak in MetNo test
This commit is contained in:
parent
62ca0a7551
commit
7e3f50c5d7
1 changed files with 14 additions and 4 deletions
|
|
@ -219,8 +219,21 @@ fn parseForecastDays(allocator: std.mem.Allocator, timeseries: []std.json.Value)
|
|||
var day_temps: std.ArrayList(f32) = .empty;
|
||||
defer day_temps.deinit(allocator);
|
||||
var day_hourly: std.ArrayList(types.HourlyForecast) = .empty;
|
||||
defer {
|
||||
for (day_hourly.items) |h| {
|
||||
allocator.free(h.time);
|
||||
allocator.free(h.condition);
|
||||
}
|
||||
day_hourly.deinit(allocator);
|
||||
}
|
||||
var day_all_hours: std.ArrayList(types.HourlyForecast) = .empty;
|
||||
defer day_all_hours.deinit(allocator);
|
||||
defer {
|
||||
for (day_all_hours.items) |h| {
|
||||
allocator.free(h.time);
|
||||
allocator.free(h.condition);
|
||||
}
|
||||
day_all_hours.deinit(allocator);
|
||||
}
|
||||
var day_symbol: ?[]const u8 = null;
|
||||
|
||||
for (timeseries) |entry| {
|
||||
|
|
@ -360,9 +373,6 @@ fn parseForecastDays(allocator: std.mem.Allocator, timeseries: []std.json.Value)
|
|||
}
|
||||
}
|
||||
|
||||
// Don't forget to deinit day_hourly if we didn't transfer ownership
|
||||
day_hourly.deinit(allocator);
|
||||
|
||||
return days.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue