FreeBSD isn't evil - just misguided
[cvsps-yd/commitid.git] / cbtcommon / hash.h
blob797e3b34a4417e0cbb0e1d2ba8f446424e89bf7e
1 /*
2 * Copyright 2001, 2002, 2003 David Mansfield and Cobite, Inc.
3 * See COPYING file for license information
4 */
6 #ifndef _COMMON_HASH_H
7 #define _COMMON_HASH_H
9 #include "list.h"
11 struct hash_entry
13 char *he_key;
14 void *he_obj;
15 struct list_head he_list;
18 struct hash_table
20 int ht_size;
21 struct list_head *ht_lists;
22 int iterator;
23 struct list_head *iterator_ptr;
26 enum
28 HT_NO_KEYCOPY,
29 HT_KEYCOPY
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 struct hash_table *create_hash_table(unsigned int sz);
37 void destroy_hash_table(struct hash_table *tbl, void (*delete_obj)(void *));
38 void *put_hash_object(struct hash_table *tbl, const char *key, void *obj);
39 void *get_hash_object(struct hash_table *tbl, const char *key);
40 void *remove_hash_object(struct hash_table *tbl, const char *key);
42 int put_hash_object_ex(struct hash_table *tbl, const char *key, void *obj, int, char **, void **);
43 void destroy_hash_table_ex(struct hash_table *tbl, void (*delete_entry)(const void *, char *, void *), const void *);
45 void reset_hash_iterator(struct hash_table *tbl);
46 struct hash_entry *next_hash_entry(struct hash_table *tbl);
48 #ifdef __cplusplus
50 #endif
52 #endif /* _COMMON_HASH_H */