LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions | Variables
tif_hash_set.c File Reference

Implement callback-driven buckets, recycled nodes, and element disposal. More...

#include "tiffiop.h"
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for tif_hash_set.c:

Go to the source code of this file.

Data Structures

struct  _TIFFList
 Link a live hash element or a recycled node. More...
 
struct  _TIFFHashSet
 Own bucket/node storage and record callback-defined element policy. More...
 

Typedefs

typedef struct _TIFFList TIFFList
 Name a private live/recycled hash-list node.
 

Functions

static unsigned long TIFFHashSetHashPointer (const void *elt)
 Hash a pointer value without dereferencing it.
 
static bool TIFFHashSetEqualPointer (const void *elt1, const void *elt2)
 Compare pointer values without dereferencing them.
 
TIFFHashSet * TIFFHashSetNew (TIFF *tif, TIFFHashSetHashFunc fnHashFunc, TIFFHashSetEqualFunc fnEqualFunc, TIFFHashSetFreeEltFunc fnFreeEltFunc)
 Allocate an empty hash set with optional ownership callbacks.
 
int TIFFHashSetSize (const TIFFHashSet *set)
 Return the current live-element count.
 
static TIFFList * TIFFHashSetGetNewListElt (TIFFHashSet *set)
 Acquire a detached node from the cache or the set's TIFF allocator.
 
static void TIFFHashSetReturnListElt (TIFFHashSet *set, TIFFList *psList)
 Recycle a detached node or free it when the cache is full.
 
static void TIFFHashSetClearInternal (TIFFHashSet *set, bool bFinalize)
 Unlink live buckets and dispose their elements as configured.
 
static void TIFFListDestroy (TIFF *tif, TIFFList *psList)
 Free a node chain without disposing its payload fields.
 
void TIFFHashSetDestroy (TIFFHashSet *set)
 Release a hash set and dispose its live elements if configured.
 
static bool TIFFHashSetRehash (TIFFHashSet *set)
 Replace the bucket array using the selected prime-capacity index.
 
static void ** TIFFHashSetFindPtr (TIFFHashSet *set, const void *elt)
 Find the mutable payload slot for a matching key.
 
bool TIFFHashSetInsert (TIFFHashSet *set, void *elt)
 Insert an element or replace an equal element.
 
void * TIFFHashSetLookup (TIFFHashSet *set, const void *elt)
 Find a borrowed stored element matching a key.
 
static bool TIFFHashSetRemoveInternal (TIFFHashSet *set, const void *elt, bool bDeferRehash)
 Remove a matching element with immediate or deferred shrink handling.
 
bool TIFFHashSetRemove (TIFFHashSet *set, const void *elt)
 Remove a matching element, disposing it if configured.
 

Variables

static const int anPrimes []
 Provide the fixed sequence of supported bucket capacities.
 

Detailed Description

Implement callback-driven buckets, recycled nodes, and element disposal.

Definition in file tif_hash_set.c.