Add LfIdMap and generational LfSlots #12
Loading…
Reference in a new issue
No description provided.
Delete branch "fputs/slotmap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
LfIdMapand generationalLfSlotsinlfslotmap.h.LfIdMapis an open-addressed table fromuint64_tkeys to inlineuint32_tvalues. Capacity is a power of two, at least 8, and a new key grows before the load would pass 3/4. The key mix is the SplitMix64 finalizer, with no seed. Duplicate insert keeps the original value. Replace does not insert a missing key. Bucket order is unspecified.LfSlotsstores caller-ownedvoid *payloads and does not free them. A stored NULL is a successful lookup. Fresh indexes start at generation 1. Generation 0 is never issued. Reuse bumps the generation. A stale id does not free the current occupant. A generation that cannot be bumped pastUINT32_MAXstays on the free list and is not recycled, and a failed alloc does not change that list.Both handles are complete structs so the caller can own them on the stack. The fields are private.
Allocation failure is covered for id-map init, a growing id-map insert, slots init, and a growing slots alloc. Previously inserted pairs and previously issued ids stay resolvable.
Tested with
-DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF.ctest --label-exclude slow: 26/26 passed.ba6c3b134ab226aa2618