diff options
Diffstat (limited to 'lib/hash.h')
| -rw-r--r-- | lib/hash.h | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/lib/hash.h b/lib/hash.h index 11ecf75ec9..202d761a5c 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -26,65 +26,63 @@ Boston, MA 02111-1307, USA. */ DECLARE_MTYPE(HASH) DECLARE_MTYPE(HASH_BACKET) -/* Default hash table size. */ +/* Default hash table size. */ #define HASH_INITIAL_SIZE 256 /* initial number of backets. */ #define HASH_THRESHOLD 10 /* expand when backet. */ #define HASHWALK_CONTINUE 0 #define HASHWALK_ABORT -1 -struct hash_backet -{ - /* Linked list. */ - struct hash_backet *next; +struct hash_backet { + /* Linked list. */ + struct hash_backet *next; - /* Hash key. */ - unsigned int key; + /* Hash key. */ + unsigned int key; - /* Data. */ - void *data; + /* Data. */ + void *data; }; -struct hash -{ - /* Hash backet. */ - struct hash_backet **index; +struct hash { + /* Hash backet. */ + struct hash_backet **index; - /* Hash table size. Must be power of 2 */ - unsigned int size; + /* Hash table size. Must be power of 2 */ + unsigned int size; - /* If expansion failed. */ - int no_expand; + /* If expansion failed. */ + int no_expand; - /* Key make function. */ - unsigned int (*hash_key) (void *); + /* Key make function. */ + unsigned int (*hash_key)(void *); - /* Data compare function. */ - int (*hash_cmp) (const void *, const void *); + /* Data compare function. */ + int (*hash_cmp)(const void *, const void *); - /* Backet alloc. */ - unsigned long count; + /* Backet alloc. */ + unsigned long count; }; -extern struct hash *hash_create (unsigned int (*) (void *), - int (*) (const void *, const void *)); -extern struct hash *hash_create_size (unsigned int, unsigned int (*) (void *), - int (*) (const void *, const void *)); +extern struct hash *hash_create(unsigned int (*)(void *), + int (*)(const void *, const void *)); +extern struct hash *hash_create_size(unsigned int, unsigned int (*)(void *), + int (*)(const void *, const void *)); -extern void *hash_get (struct hash *, void *, void * (*) (void *)); -extern void *hash_alloc_intern (void *); -extern void *hash_lookup (struct hash *, void *); -extern void *hash_release (struct hash *, void *); +extern void *hash_get(struct hash *, void *, void *(*)(void *)); +extern void *hash_alloc_intern(void *); +extern void *hash_lookup(struct hash *, void *); +extern void *hash_release(struct hash *, void *); -extern void hash_iterate (struct hash *, - void (*) (struct hash_backet *, void *), void *); +extern void hash_iterate(struct hash *, void (*)(struct hash_backet *, void *), + void *); -extern void hash_walk (struct hash *, - int (*) (struct hash_backet *, void *), void *); +extern void hash_walk(struct hash *, int (*)(struct hash_backet *, void *), + void *); -extern void hash_clean (struct hash *, void (*) (void *)); -extern void hash_free (struct hash *); +extern void hash_clean(struct hash *, void (*)(void *)); +extern void hash_free(struct hash *); -extern unsigned int string_hash_make (const char *); +extern unsigned int string_hash_make(const char *); #endif /* _ZEBRA_HASH_H */ |
