From ec0d36ee55709f1df76f977823722a4b53cf27ed Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 3 May 2008 02:36:31 +0000 Subject: A whole bunch of changes including: * Measure disk space * Support mulitple IPs per jail. --- common/hash.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'common/hash.c') diff --git a/common/hash.c b/common/hash.c index 9acd2df..b509d03 100644 --- a/common/hash.c +++ b/common/hash.c @@ -286,6 +286,11 @@ static hsh_entry_t** find_entry(hsh_t* ht, const void* key, size_t klen, const v klen = p - (const unsigned char *)key; } + else if(klen == HSH_KEY_DIRECT) + { + hash = (unsigned int)key; + klen = 0; + } else { for(p = key, i = klen; i; i--, p++) @@ -374,6 +379,25 @@ void* hsh_rem(hsh_t* ht, const void* key, size_t klen) return val; } +void hsh_clear(hsh_t* ht) +{ + hsh_entry_t *he, *next; + int i; + + /* Free all entries in the array */ + for (i = 0; i < ht->max; ++i) { + he = ht->array[i]; + while (he) { + next = he->next; + free (he); + he = next; + } + } + + memset (ht->array, 0, ht->max * sizeof (hsh_entry_t*)); + ht->count = 0; +} + unsigned int hsh_count(hsh_t* ht) { return ht->count; -- cgit v1.2.3