pub fn ensureTotalCapacityContext(self: *Self, gpa: Allocator, new_capacity: usize, ctx: Context) Oom!void 416
417
418
419
420
421
422
423
424
425
426
427
428
429
430 pub fn ensureTotalCapacityContext(self: *Self, gpa: Allocator, new_capacity: usize, ctx: Context) Oom!void {
self.pointer_stability.lock();
defer self.pointer_stability.unlock();
try self.entries.ensureTotalCapacity(gpa, new_capacity);
if (new_capacity <= linear_scan_max) return;
if (self.index_header) |header| if (new_capacity <= header.capacity()) return;
const new_bit_index = try IndexHeader.findBitIndex(new_capacity);
const new_header = try IndexHeader.alloc(gpa, new_bit_index);
if (self.index_header) |old_header| old_header.free(gpa);
self.insertAllEntriesIntoNewHeader(if (store_hash) {} else ctx, new_header);
self.index_header = new_header;
}