summaryrefslogtreecommitdiff
path: root/ckcapi-util.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2007-04-29 00:20:38 +0000
committerStef Walter <stef@memberwebs.com>2007-04-29 00:20:38 +0000
commit856a057fc0a0807e9c0dd2b11c04e1f1312bdb12 (patch)
tree1286bdecc6beb0d43cfc883016e8d8f834e8d119 /ckcapi-util.c
parent31366290fcfbb7b51332e41755ba3f0c4b01084f (diff)
Fix tons of bugs and performance issues to better list the certificates.
Diffstat (limited to 'ckcapi-util.c')
-rw-r--r--ckcapi-util.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/ckcapi-util.c b/ckcapi-util.c
index 3c587ac..7fd1d1d 100644
--- a/ckcapi-util.c
+++ b/ckcapi-util.c
@@ -202,7 +202,7 @@ typedef struct _HashEntry
unsigned int hash;
const void* key;
size_t klen;
- const void* val;
+ void* val;
}
HashEntry;
@@ -252,17 +252,19 @@ ckcapi_hash_new()
}
void
-ckcapi_hash_free(CkCapiHash* ht)
+ckcapi_hash_free(CkCapiHash* ht, CkCapiHashDestroy destroy_func)
{
HashEntry* he;
HashEntry* next;
size_t i;
- for(i = 0; i < ht->max; ++i)
+ for(i = 0; i <= ht->max; ++i)
{
for(he = ht->array[i]; he; )
{
next = he->next;
+ if(destroy_func)
+ (destroy_func)((void*)he->val);
free(he);
he = next;
}
@@ -290,13 +292,13 @@ expand_array(CkCapiHash* ht)
if(!new_array)
return 0;
- for(i = 0; i < ht->max; ++i)
+ for(i = 0; i <= ht->max; ++i)
{
for(he = ht->array[i]; he; he = he->next)
{
- unsigned int i = he->hash & new_max;
- he->next = new_array[i];
- new_array[i] = he;
+ unsigned int j = he->hash & new_max;
+ he->next = new_array[j];
+ new_array[j] = he;
}
}
@@ -318,7 +320,7 @@ expand_array(CkCapiHash* ht)
*/
static HashEntry**
-find_entry(CkCapiHash* ht, const void* key, size_t klen, const void* val)
+find_entry(CkCapiHash* ht, const void* key, size_t klen, void* val)
{
HashEntry** hep;
HashEntry* he;