124 53, 97, 193, 389, 769, 1543, 3079,
125 6151, 12289, 24593, 49157, 98317, 196613, 393241,
126 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653,
127 100663319, 201326611, 402653189, 805306457, 1610612741};
147 return (
unsigned long)(uintptr_t)((
void *)(elt));
198 set->nCollisions = 0;
368 set->nCollisions = 0;
377void TIFFHashSetForeach(
TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc,
389 if (!fnIterFunc(cur->
pData, user_data))
423 if (newTabList == NULL)
426 TIFFDebug(
"TIFFHASH",
427 "hashSet=%p, nSize=%d, nCollisions=%d, "
428 "fCollisionRate=%.02f",
429 set, set->
nSize, set->nCollisions,
430 set->nCollisions * 100.0 / set->
nSize);
431 set->nCollisions = 0;
438 const unsigned long nNewHashVal =
441 if (newTabList[nNewHashVal])
445 cur->
psNext = newTabList[nNewHashVal];
446 newTabList[nNewHashVal] = cur;
477 const unsigned long nHashVal =
520 const unsigned long nHashVal =
534 new_elt->
pData = elt;
536 set->
tabList[nHashVal] = new_elt;
644bool TIFFHashSetRemoveDeferRehash(
TIFFHashSet *set,
const void *elt)
bool(* TIFFHashSetEqualFunc)(const void *elt1, const void *elt2)
Test whether a stored element matches another element or key.
static void TIFFHashSetReturnListElt(TIFFHashSet *set, TIFFList *psList)
Recycle a detached node or free it when the cache is full.
static unsigned long TIFFHashSetHashPointer(const void *elt)
Hash a pointer value without dereferencing it.
void * TIFFHashSetLookup(TIFFHashSet *set, const void *elt)
Find a borrowed stored element matching a key.
bool TIFFHashSetInsert(TIFFHashSet *set, void *elt)
Insert an element or replace an equal element.
bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt)
Remove a matching element, disposing it if configured.
int TIFFHashSetSize(const TIFFHashSet *set)
Return the current live-element count.
void(* TIFFHashSetFreeEltFunc)(struct tiff *tif, void *elt)
Dispose of an element according to the set's ownership policy.
static TIFFList * TIFFHashSetGetNewListElt(TIFFHashSet *set)
Acquire a detached node from the cache or the set's TIFF allocator.
static bool TIFFHashSetEqualPointer(const void *elt1, const void *elt2)
Compare pointer values without dereferencing them.
void TIFFHashSetDestroy(TIFFHashSet *set)
Release a hash set and dispose its live elements if configured.
static const int anPrimes[]
Provide the fixed sequence of supported bucket capacities.
static void TIFFListDestroy(TIFF *tif, TIFFList *psList)
Free a node chain without disposing its payload fields.
static void ** TIFFHashSetFindPtr(TIFFHashSet *set, const void *elt)
Find the mutable payload slot for a matching key.
static bool TIFFHashSetRemoveInternal(TIFFHashSet *set, const void *elt, bool bDeferRehash)
Remove a matching element with immediate or deferred shrink handling.
static void TIFFHashSetClearInternal(TIFFHashSet *set, bool bFinalize)
Unlink live buckets and dispose their elements as configured.
unsigned long(* TIFFHashSetHashFunc)(const void *elt)
Compute an element hash without changing its key.
static bool TIFFHashSetRehash(TIFFHashSet *set)
Replace the bucket array using the selected prime-capacity index.
TIFFHashSet * TIFFHashSetNew(TIFF *tif, TIFFHashSetHashFunc fnHashFunc, TIFFHashSetEqualFunc fnEqualFunc, TIFFHashSetFreeEltFunc fnFreeEltFunc)
Allocate an empty hash set with optional ownership callbacks.
void _TIFFfreeExt(TIFF *tif, void *p)
Release a handle-aware allocation and its payload charge.
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
Allocate uninitialised bytes under a handle's allocation policy.
void * _TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz)
Allocate a zero-filled array under a handle's allocation policy.
Own bucket/node storage and record callback-defined element policy.
int nIndiceAllocatedSize
Index into anPrimes; callers must keep growth/shrink selection in range.
TIFF * tif
Borrowed handle used for every set allocation and passed to fnFreeEltFunc, or NULL for unaccounted al...
TIFFList * psRecyclingList
Owned spare-node list, whose payload fields are not live elements.
TIFFHashSetEqualFunc fnEqualFunc
Borrowed equality function, with a default installed at creation.
int nSize
Live-element count in normal externally visible state.
TIFFHashSetFreeEltFunc fnFreeEltFunc
Optional consuming disposer, including for failed incoming insertions.
TIFFList ** tabList
Owned array of bucket-head pointers.
TIFFHashSetHashFunc fnHashFunc
Borrowed hash function, with a default installed at creation.
int nAllocatedSize
Logical bucket count used for hashing and traversal.
bool bRehash
Deferred rehash state used by optional deferred removal.
int nRecyclingListSize
Number of nodes in the spare-node list, capped at 128 on return.
Link a live hash element or a recycled node.
struct _TIFFList * psNext
Next live-bucket or recycling-list node.
void * pData
Live payload pointer, or stale/unused recycled value.
Hold private state for one open TIFF library instance.
Declare private library state, callbacks, and implementation helpers.