hash.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  _hash_link
struct  _hash_table


#define DEFAULT_HASH_SIZE   7951


typedef unsigned int HASHHASH (const void *, unsigned int)
typedef int HASHCMP (const void *, const void *)
typedef struct _hash_link hash_link
typedef struct _hash_table hash_table


hash_tablehash_create (HASHCMP *, int, HASHHASH *)
void hash_insert (hash_table *, const char *, void *)
int hash_delete (hash_table *, const char *)
int hash_delete_link (hash_table *, hash_link *)
int hash_unlink (hash_table *, hash_link *, int)
void hash_join (hash_table *, hash_link *)
int hash_remove_link (hash_table *, hash_link *)
hash_linkhash_lookup (hash_table *, const void *)
hash_linkhash_first (hash_table *)
hash_linkhash_next (hash_table *)
hash_linkhash_get_bucket (hash_table *, unsigned int)
void hashFreeMemory (hash_table *)


int hash_links_allocated
HASHHASH hash_string
HASHHASH hash_url

Macro Definition Documentation

#define DEFAULT_HASH_SIZE   7951

Definition at line 9 of file hash.h.

Typedef Documentation

typedef struct _hash_link hash_link

Definition at line 19 of file hash.h.

typedef struct _hash_table hash_table

Definition at line 30 of file hash.h.

typedef int HASHCMP(const void *, const void *)

Definition at line 17 of file hash.h.

typedef unsigned int HASHHASH(const void *, unsigned int)

Definition at line 11 of file hash.h.

Function Documentation

hash_table* hash_create ( HASHCMP cmp_func,
int  hash_sz,
HASHHASH hash_func 

hash_create - creates a new hash table, uses the cmp_func to compare keys. Returns the identification for the hash table; otherwise returns a negative number on error.

Definition at line 109 of file hash.cc.

References hash_table::buckets, hash_table::cmp, hash_table::current_slot, DEFAULT_HASH_SIZE, hash_table::hash, int, hash_table::next, NULL, hash_table::size, and xcalloc.

int hash_delete ( hash_table ,
const char *   

Definition at line 255 of file hash.c.

References hash_delete_link(), and hash_lookup().

int hash_delete_link ( hash_table ,

Definition at line 299 of file hash.c.

References hash_unlink().

Referenced by hash_delete().

hash_link* hash_first ( hash_table hid)

hash_first - initializes the hash table for the hash_next() function.

Definition at line 176 of file hash.cc.

References assert, hash_table::buckets, hash_table::current_slot, hash_next_bucket(), i, hash_table::next, NULL, and hash_table::size.

hash_link* hash_get_bucket ( hash_table hid,
unsigned int  bucket 

hash_get_bucket - returns the head item of the bucket in the hash table 'hid'. Otherwise, returns NULL on error.

Definition at line 248 of file hash.cc.

References hash_table::buckets, NULL, and hash_table::size.

void hash_insert ( hash_table ,
const char *  ,
void *   

Definition at line 158 of file hash.c.

References assert, hash_table::buckets, hash_table::hash, i, NULL, print_stats(), and hash_table::size.

Referenced by my_hash_insert().

void hash_join ( hash_table hid,
hash_link lnk 

hash_join - joins a hash_link under its key lnk->key into the hash table 'hid'.

It does not copy any data into the hash table, only links pointers.

Definition at line 132 of file hash.cc.

References hash_table::buckets, hash_table::count, hash_table::hash, i, hash_link::key, hash_link::next, and hash_table::size.

hash_link* hash_lookup ( hash_table hid,
const void *  k 

hash_lookup - locates the item under the key 'k' in the hash table 'hid'. Returns a pointer to the hash bucket on success; otherwise returns NULL.

Definition at line 147 of file hash.cc.

References assert, hash_table::buckets, hash_table::cmp, hash_table::hash, hash_lookup(), hash_link::key, hash_link::next, NULL, PROF_start, PROF_stop, and hash_table::size.

hash_link* hash_next ( hash_table hid)

hash_next - returns the next item in the hash table 'hid'. Otherwise, returns NULL on error or end of list.

MUST call hash_first() before hash_next().

Definition at line 192 of file hash.cc.

References hash_table::buckets, hash_table::current_slot, hash_next_bucket(), i, hash_link::next, hash_table::next, NULL, p, and size.

int hash_remove_link ( hash_table hid,
hash_link hl 

hash_remove_link - deletes the given hash_link node from the hash table 'hid'. Does not free the item, only removes it from the list.

An assertion is triggered if the hash_link is not found in the list.

Definition at line 224 of file hash.cc.

References assert, hash_table::buckets, hash_table::count, hash_table::hash, hash_next_bucket(), hash_unlink(), i, hash_link::key, hash_link::next, hash_table::next, NULL, and hash_table::size.

int hash_unlink ( hash_table ,
hash_link ,
void hashFreeMemory ( hash_table )

Definition at line 272 of file hash.cc.

References hash_table::buckets, free, NULL, and xfree.

Variable Documentation


Definition at line 50 of file hash.h.

int hash_links_allocated
HASHHASH hash_string

Definition at line 48 of file hash.h.

HASHHASH hash_url

Definition at line 49 of file hash.h.






Web Site Translations