/*++ /* NAME /* binhash 3 /* SUMMARY /* hash table manager /* SYNOPSIS /* #include <binhash.h> /* /* typedef struct { /* .in +4 /* void *key; /* ssize_t key_len; /* void *value;
/* /* private fields... */ /* .in -4 /* } BINHASH_INFO; /* /* BINHASH *binhash_create(size) /* ssize_t size; /* /* BINHASH_INFO *binhash_enter(table, key, key_len, value) /* BINHASH *table; /* const void *key; /* ssize_t key_len; /* void *value; /* /* char *binhash_find(table, key, key_len) /* BINHASH *table; /* const void *key; /* ssize_t key_len; /* /* BINHASH_INFO *binhash_locate(table, key, key_len) /* BINHASH *table; /* const void *key; /* ssize_t key_len; /* /* void binhash_delete(table, key, key_len, free_fn) /* BINHASH *table; /* const void *key; /* ssize_t key_len; /* void (*free_fn)(void *); /* /* void binhash_free(table, free_fn) /* BINHASH *table; /* void (*free_fn)(void *); /* /* void binhash_walk(table, action, ptr) /* BINHASH *table; /* void (*action)(BINHASH_INFO *info, void *ptr); /* void *ptr; /* /* BINHASH_INFO **binhash_list(table) /* BINHASH *table; /* /* BINHASH_INFO *binhash_sequence(table, how) /* BINHASH *table; /* int how; /* DESCRIPTION /* This module maintains one or more hash tables. Each table entry /* consists of a unique binary-valued lookup key and a generic /* character-pointer value. /* The tables are automatically resized when they fill up. When the /* values to be remembered are not character pointers, proper casts /* should be used or the code will not be portable. /* /* binhash_create() creates a table of the specified size and returns a /* pointer to the result. The lookup keys are saved with mymemdup(). /* /* binhash_enter() stores a (key, value) pair into the specified table /* and returns a pointer to the resulting entry. The code does not /* check if an entry with that key already exists: use binhash_locate() /* for updating an existing entry. The key is copied; the value is not. /* /* binhash_find() returns the value that was stored under the given key, /* or a null pointer if it was not found. In order to distinguish /* a null value from a non-existent value, use binhash_locate(). /* /* binhash_locate() returns a pointer to the entry that was stored /* for the given key, or a null pointer if it was not found. /* /* binhash_delete() removes one entry that was stored under the given key. /* If the free_fn argument is not a null pointer, the corresponding /* function is called with as argument the value that was stored under /* the key. /* /* binhash_free() destroys a hash table, including contents. If the free_fn /* argument is not a null pointer, the corresponding function is called /* for each table entry, with as argument the value that was stored /* with the entry. /* /* binhash_walk() invokes the action function for each table entry, with /* a pointer to the entry as its argument. The ptr argument is passed /* on to the action function. /* /* binhash_list() returns a null-terminated list of pointers to /* all elements in the named table. The list should be passed to /* myfree(). /* /* binhash_sequence() returns the first or next element /* depending on the value of the "how" argument. Specify /* BINHASH_SEQ_FIRST to start a new sequence, BINHASH_SEQ_NEXT /* to continue, and BINHASH_SEQ_STOP to terminate a sequence /* early. The caller must not delete an element before it is /* visited. /* RESTRICTIONS /* A callback function should not modify the hash table that is /* specified to its caller. /* DIAGNOSTICS /* The following conditions are reported and cause the program to /* terminate immediately: memory allocation failure; an attempt /* to delete a non-existent entry. /* SEE ALSO /* mymalloc(3) memory management wrapper /* hash_fnv(3) Fowler/Noll/Vo hash function /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.