Skip to content

Commit

Permalink
fix compile errors in src/binned_allocator.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Nov 3, 2024
1 parent 185752d commit eed12d3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/binned_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ pub const Config = struct {
pub fn BinnedAllocator(comptime config: Config) type {
return struct {
backing_allocator: std.mem.Allocator = std.heap.page_allocator,
bins: Bins = .{},
bins: Bins = .{ .{}, .{}, .{}, .{}, .{} },
large_count: if (config.report_leaks) Counter else void = if (config.report_leaks) Counter.init(),

const Bins = struct {
Bin(16, 8) = .{},
Bin(64, 4) = .{},
Bin(256, 2) = .{},
Bin(1024, 0) = .{},
Bin(4096, 0) = .{},
Bin(16, 8),
Bin(64, 4),
Bin(256, 2),
Bin(1024, 0),
Bin(4096, 0),
};
comptime {
var prev: usize = 0;
for (Bins{}) |bin| {
std.debug.assert(bin.size > prev);
prev = bin.size;
for (std.meta.fields(Bins)) |bin_field| {
const bin_size = (bin_field.type{}).size;
std.debug.assert(bin_size > prev);
prev = bin_size;
}
}

Expand Down

0 comments on commit eed12d3

Please sign in to comment.