fn alloc(gpa: Allocator, new_bit_index: u8) Allocator.Error!*IndexHeader gpa: Allocatornew_bit_index: u81688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699 fn alloc(gpa: Allocator, new_bit_index: u8) Allocator.Error!*IndexHeader {
const len = @as(usize, 1) << @as(math.Log2Int(usize), @intCast(new_bit_index));
const index_size = hash_map.capacityIndexSize(new_bit_index);
const nbytes = @sizeOf(IndexHeader) + index_size * len;
const bytes = try gpa.alignedAlloc(u8, .of(IndexHeader), nbytes);
@memset(bytes[@sizeOf(IndexHeader)..], 0xff);
const result: *IndexHeader = @ptrCast(@alignCast(bytes.ptr));
result.* = .{
.bit_index = new_bit_index,
};
return result;
}
Allocates an index header, and fills the entryIndexes array with empty. The distance array contents are undefined.