diff options
author | Stef Walter <stef@memberwebs.com> | 2004-07-22 16:55:14 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-07-22 16:55:14 +0000 |
commit | 6be6d1dd25f2e7f2f1de6c0091e9aeae2ea1918c (patch) | |
tree | 1454a6bb0ec09fb6b105171d7aab29a217b30a39 /common/hash.h | |
parent | 166f69df6dd704626c1b09ae60145956435b67e1 (diff) |
- Fixed uninitialized memory bug
- Imported updated sock_any and hash code
Diffstat (limited to 'common/hash.h')
-rw-r--r-- | common/hash.h | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/common/hash.h b/common/hash.h index 174c209..fef2803 100644 --- a/common/hash.h +++ b/common/hash.h @@ -18,8 +18,8 @@ * limitations under the License. */ -#ifndef __HASH_H__ -#define __HASH_H__ +#ifndef __HSH_H__ +#define __HSH_H__ #ifdef __cplusplus extern "C" { @@ -35,13 +35,13 @@ extern "C" { */ /* Keep timestamps for the entries */ -#define HASH_TIMESTAMP +#define HSH_TIMESTAMP /* Keep key values internally */ -#define HASH_COPYKEYS +#define HSH_COPYKEYS /* Hash callback functionality */ -#define HASH_CALLBACKS +#define HSH_CALLBACKS /* * ARGUMENT DOCUMENTATION @@ -60,10 +60,10 @@ extern "C" { */ /* Abstract type for hash tables. */ -typedef struct hash_t hash_t; +typedef struct hsh_t hsh_t; /* Abstract type for scanning hash tables. */ -typedef struct hash_index_t hash_index_t; +typedef struct hsh_index_t hsh_index_t; /* ---------------------------------------------------------------------------------- @@ -73,60 +73,60 @@ typedef struct hash_index_t hash_index_t; * keys stored in the hashtable itself. */ -#ifdef HASH_COPYKEYS +#ifdef HSH_COPYKEYS /* - * hash_create : Create a hash table + * hsh_create : Create a hash table * - returns an allocated hashtable */ -hash_t* hash_create(size_t klen); +hsh_t* hsh_create(size_t klen); /* - * hash_free : Free a hash table + * hsh_free : Free a hash table */ -void hash_free(hash_t* ht); +void hsh_free(hsh_t* ht); /* - * hash_count: Number of values in hash table + * hsh_count: Number of values in hash table * - returns the number of entries in hash table */ -unsigned int hash_count(hash_t* ht); +unsigned int hsh_count(hsh_t* ht); /* - * hash_get: Retrieves a value from the hash table + * hsh_get: Retrieves a value from the hash table * - returns the value of the entry */ -void* hash_get(hash_t* ht, const void* key); +void* hsh_get(hsh_t* ht, const void* key); /* - * hash_set: Set a value in the hash table + * hsh_set: Set a value in the hash table * - returns 1 if the entry was added properly */ -int hash_set(hash_t* ht, const void* key, void* val); +int hsh_set(hsh_t* ht, const void* key, void* val); /* - * hash_rem: Remove a value from the hash table + * hsh_rem: Remove a value from the hash table * - returns the value of the removed entry */ -void* hash_rem(hash_t* ht, const void* key); +void* hsh_rem(hsh_t* ht, const void* key); /* - * hash_first: Start enumerating through the hash table + * hsh_first: Start enumerating through the hash table * - returns a hash iterator */ -hash_index_t* hash_first(hash_t* ht); +hsh_index_t* hsh_first(hsh_t* ht); /* - * hash_next: Enumerate through hash table + * hsh_next: Enumerate through hash table * - returns the hash iterator or null when no more entries */ -hash_index_t* hash_next(hash_index_t* hi); +hsh_index_t* hsh_next(hsh_index_t* hi); /* - * hash_this: While enumerating get current value + * hsh_this: While enumerating get current value * - returns the value that the iterator currently points to */ -void* hash_this(hash_index_t* hi, const void** key); +void* hsh_this(hsh_index_t* hi, const void** key); @@ -140,63 +140,63 @@ void* hash_this(hash_index_t* hi, const void** key); #else /* - * hash_create : Create a hash table + * hsh_create : Create a hash table * - returns an allocated hashtable */ -hash_t* hash_create(); +hsh_t* hsh_create(); /* - * hash_free : Free a hash table + * hsh_free : Free a hash table */ -void hash_free(hash_t* ht); +void hsh_free(hsh_t* ht); /* - * hash_count: Number of values in hash table + * hsh_count: Number of values in hash table * - returns the number of entries in hash table */ -unsigned int hash_count(hash_t* ht); +unsigned int hsh_count(hsh_t* ht); /* - * hash_get: Retrieves a value from the hash table + * hsh_get: Retrieves a value from the hash table * - returns the value of the entry */ -void* hash_get(hash_t* ht, const void* key, size_t klen); +void* hsh_get(hsh_t* ht, const void* key, size_t klen); /* - * hash_set: Set a value in the hash table + * hsh_set: Set a value in the hash table * - returns 1 if the entry was added properly */ -int hash_set(hash_t* ht, const void* key, size_t klen, void* val); +int hsh_set(hsh_t* ht, const void* key, size_t klen, void* val); /* - * hash_rem: Remove a value from the hash table + * hsh_rem: Remove a value from the hash table * - returns the value of the removed entry */ -void* hash_rem(hash_t* ht, const void* key, size_t klen); +void* hsh_rem(hsh_t* ht, const void* key, size_t klen); /* - * hash_first: Start enumerating through the hash table + * hsh_first: Start enumerating through the hash table * - returns a hash iterator */ -hash_index_t* hash_first(hash_t* ht); +hsh_index_t* hsh_first(hsh_t* ht); /* - * hash_next: Enumerate through hash table + * hsh_next: Enumerate through hash table * - returns the hash iterator or null when no more entries */ -hash_index_t* hash_next(hash_index_t* hi); +hsh_index_t* hsh_next(hsh_index_t* hi); /* - * hash_this: While enumerating get current value + * hsh_this: While enumerating get current value * - returns the value that the iterator currently points to */ -void* hash_this(hash_index_t* hi, const void** key, size_t* klen); +void* hsh_this(hsh_index_t* hi, const void** key, size_t* klen); /* * This can be passed as 'klen' in any of the above functions to indicate * a string-valued key, and have hash compute the length automatically. */ -#define HASH_KEY_STRING (-1) +#define HSH_KEY_STRING (-1) #endif @@ -210,27 +210,27 @@ void* hash_this(hash_index_t* hi, const void** key, size_t* klen); * functions in addition to one of the above 'key' modes. */ -#ifdef HASH_TIMESTAMP +#ifdef HSH_TIMESTAMP /* - * hash_purge: Purge entries before a certain timestamp + * hsh_purge: Purge entries before a certain timestamp * - returns the number of entries purged */ -int hash_purge(hash_t* ht, time_t stamp); +int hsh_purge(hsh_t* ht, time_t stamp); /* - * hash_touch: Touch an entry to make it's timestamp current + * hsh_touch: Touch an entry to make it's timestamp current */ -#ifdef HASH_COPYKEYS - void hash_touch(hash_t* ht, const void* key); +#ifdef HSH_COPYKEYS + void hsh_touch(hsh_t* ht, const void* key); #else - void hash_touch(hash_t* ht, const void* key, size_t* klen); + void hsh_touch(hsh_t* ht, const void* key, size_t* klen); #endif /* - * hash_bump: Bumps the oldest entry out + * hsh_bump: Bumps the oldest entry out */ -int hash_bump(hash_t* ht); +int hsh_bump(hsh_t* ht); #endif @@ -243,34 +243,34 @@ int hash_bump(hash_t* ht); * well as to get callbacks when an item is discarded. */ -#ifdef HASH_CALLBACKS +#ifdef HSH_CALLBACKS -typedef void* (*hash_falloc)(void* arg, size_t len); -typedef void (*hash_ffree)(void* arg, void* ptr); +typedef void* (*hsh_falloc)(void* arg, size_t len); +typedef void (*hsh_ffree)(void* arg, void* ptr); -typedef struct hash_memory_calls +typedef struct hsh_memory_calls { - hash_falloc f_alloc; - hash_ffree f_free; + hsh_falloc f_alloc; + hsh_ffree f_free; void* arg; } -hash_memory_calls_t; +hsh_memory_calls_t; /* Set the global memory calls */ -void hash_set_memory_calls(hash_memory_calls_t* hmc); +void hsh_set_memory_calls(hsh_memory_calls_t* hmc); -typedef void (*hash_ffreeval)(void* arg, void* val); +typedef void (*hsh_ffreeval)(void* arg, void* val); -typedef struct hash_table_calls +typedef struct hsh_table_calls { - hash_ffreeval f_freeval; + hsh_ffreeval f_freeval; void* arg; } -hash_table_calls_t; +hsh_table_calls_t; /* Set the per table free value call */ -void hash_set_table_calls(hash_t* ht, hash_table_calls_t* htc); +void hsh_set_table_calls(hsh_t* ht, hsh_table_calls_t* htc); #endif @@ -281,4 +281,4 @@ void hash_set_table_calls(hash_t* ht, hash_table_calls_t* htc); } #endif -#endif /* __HASH_H__ */ +#endif /* __HSH_H__ */ |