DoxigAlpha

alloc

Allocates an index header, and fills the entryIndexes array with empty. The distance array contents are undefined.

Function parameters

Parameters

#
new_bit_index:u8

Type definitions in this namespace

Types

#

An `ArrayHashMap` with default hash and equal functions.

Functions

#
AutoArrayHashMap
An `ArrayHashMap` with default hash and equal functions.
AutoArrayHashMapUnmanaged
An `ArrayHashMapUnmanaged` with default hash and equal functions.
StringArrayHashMap
An `ArrayHashMap` with strings as keys.
StringArrayHashMapUnmanaged
An `ArrayHashMapUnmanaged` with strings as keys.
ArrayHashMap
Deprecated in favor of `ArrayHashMapWithAllocator` (no code changes needed)
ArrayHashMapWithAllocator
A hash table of keys and values, each stored sequentially.
ArrayHashMapUnmanaged
A hash table of keys and values, each stored sequentially.

Source

Implementation

#
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;
}