netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
hash.c File Reference
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "hash.h"

Macros

#define NDEBUG
#define HASH_IMPLEMENTATION
#define INIT_BITS   6
#define INIT_SIZE   (1UL << (INIT_BITS))
#define INIT_MASK   ((INIT_SIZE) - 1)
#define next   hash_next
#define key   hash_key
#define data   hash_data
#define hkey   hash_hkey
#define table   hash_table
#define nchains   hash_nchains
#define nodecount   hash_nodecount
#define maxcount   hash_maxcount
#define highmark   hash_highmark
#define lowmark   hash_lowmark
#define compare   hash_compare
#define function   hash_function
#define allocnode   hash_allocnode
#define freenode   hash_freenode
#define context   hash_context
#define mask   hash_mask
#define dynamic   hash_dynamic
#define table   hash_table
#define chain   hash_chain
#define get16bits(d)

Functions

static hnode_thnode_alloc (void *context)
static void hnode_free (hnode_t *node, void *context)
static hash_val_t hash_fun_default (const void *key)
static int hash_comp_default (const void *key1, const void *key2)
static void compute_bits (void)
static int is_power_of_two (hash_val_t arg)
static void clear_table (hash_t *hash)
static void grow_table (hash_t *hash)
static void shrink_table (hash_t *hash)
hash_thash_create (hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun)
void hash_set_allocator (hash_t *hash, hnode_alloc_t al, hnode_free_t fr, void *context)
void hash_free_nodes (hash_t *hash)
void hash_destroy (hash_t *hash)
void hash_scan_begin (hscan_t *scan, hash_t *hash)
hnode_thash_scan_next (hscan_t *scan)
void hash_insert (hash_t *hash, hnode_t *node, const void *key)
hnode_thash_lookup (hash_t *hash, const void *key)
hnode_thash_delete (hash_t *hash, hnode_t *node)
int hash_alloc_insert (hash_t *hash, const void *key, void *data)
void hash_delete_free (hash_t *hash, hnode_t *node)
hnode_thash_scan_delete (hash_t *hash, hnode_t *node)
void hash_scan_delfree (hash_t *hash, hnode_t *node)
int hash_verify (hash_t *hash)
static hnode_thnode_alloc (void *context _U_)
static void hnode_free (hnode_t *node, void *context _U_)
hnode_thnode_init (hnode_t *hnode, void *data)
void * hnode_get (hnode_t *node)
const void * hnode_getkey (hnode_t *node)
hashcount_t hash_count (hash_t *hash)
hashcount_t hash_size (hash_t *hash)

Variables

int hash_val_t_bit

Macro Definition Documentation

◆ allocnode

#define allocnode   hash_allocnode

◆ chain

#define chain   hash_chain

◆ compare

#define compare   hash_compare

◆ context

#define context   hash_context

◆ data

#define data   hash_data

◆ dynamic

#define dynamic   hash_dynamic

◆ freenode

#define freenode   hash_freenode

◆ function

#define function   hash_function

◆ get16bits

#define get16bits ( d)
Value:
((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+(uint32_t)(((const uint8_t *)(d))[0]) )

◆ HASH_IMPLEMENTATION

#define HASH_IMPLEMENTATION

◆ highmark

#define highmark   hash_highmark

◆ hkey

#define hkey   hash_hkey

◆ INIT_BITS

#define INIT_BITS   6

◆ INIT_MASK

#define INIT_MASK   ((INIT_SIZE) - 1)

◆ INIT_SIZE

#define INIT_SIZE   (1UL << (INIT_BITS))

◆ key

#define key   hash_key

◆ lowmark

#define lowmark   hash_lowmark

◆ mask

#define mask   hash_mask

◆ maxcount

#define maxcount   hash_maxcount

◆ nchains

#define nchains   hash_nchains

◆ NDEBUG

#define NDEBUG

◆ next

#define next   hash_next

◆ nodecount

#define nodecount   hash_nodecount

◆ table [1/2]

#define table   hash_table

◆ table [2/2]

#define table   hash_table

Function Documentation

◆ clear_table()

void clear_table ( hash_t * hash)
static

◆ compute_bits()

void compute_bits ( void )
static

◆ grow_table()

void grow_table ( hash_t * hash)
static

◆ hash_alloc_insert()

int hash_alloc_insert ( hash_t * hash,
const void * key,
void * data )

◆ hash_comp_default()

int hash_comp_default ( const void * key1,
const void * key2 )
static

◆ hash_count()

hashcount_t hash_count ( hash_t * hash)

◆ hash_create()

hash_t * hash_create ( hashcount_t maxcount,
hash_comp_t compfun,
hash_fun_t hashfun )

◆ hash_delete()

hnode_t * hash_delete ( hash_t * hash,
hnode_t * node )

◆ hash_delete_free()

void hash_delete_free ( hash_t * hash,
hnode_t * node )

◆ hash_destroy()

void hash_destroy ( hash_t * hash)

◆ hash_free_nodes()

void hash_free_nodes ( hash_t * hash)

◆ hash_fun_default()

hash_val_t hash_fun_default ( const void * key)
static

◆ hash_insert()

void hash_insert ( hash_t * hash,
hnode_t * node,
const void * key )

◆ hash_lookup()

hnode_t * hash_lookup ( hash_t * hash,
const void * key )

◆ hash_scan_begin()

void hash_scan_begin ( hscan_t * scan,
hash_t * hash )

◆ hash_scan_delete()

hnode_t * hash_scan_delete ( hash_t * hash,
hnode_t * node )

◆ hash_scan_delfree()

void hash_scan_delfree ( hash_t * hash,
hnode_t * node )

◆ hash_scan_next()

hnode_t * hash_scan_next ( hscan_t * scan)

◆ hash_set_allocator()

void hash_set_allocator ( hash_t * hash,
hnode_alloc_t al,
hnode_free_t fr,
void * context )

◆ hash_size()

hashcount_t hash_size ( hash_t * hash)

◆ hash_verify()

int hash_verify ( hash_t * hash)

◆ hnode_alloc() [1/2]

hnode_t * hnode_alloc ( void *context _U_)
static

◆ hnode_alloc() [2/2]

hnode_t * hnode_alloc ( void * context)
static

◆ hnode_free() [1/2]

void hnode_free ( hnode_t * node,
void *context _U_ )
static

◆ hnode_free() [2/2]

void hnode_free ( hnode_t * node,
void * context )
static

◆ hnode_get()

void * hnode_get ( hnode_t * node)

◆ hnode_getkey()

const void * hnode_getkey ( hnode_t * node)

◆ hnode_init()

hnode_t * hnode_init ( hnode_t * hnode,
void * data )

◆ is_power_of_two()

int is_power_of_two ( hash_val_t arg)
static

◆ shrink_table()

void shrink_table ( hash_t * hash)
static

Variable Documentation

◆ hash_val_t_bit

int hash_val_t_bit