updates.
[silc.git] / lib / silccore / idcache.c
index ee557dce87a8c5be33a9c3838d008b3294553735..e5665f42ec43d2a75123a0132a91adb54fc10431 100644 (file)
@@ -109,12 +109,13 @@ SilcIDCache silc_idcache_alloc(uint32 count, SilcIdType id_type,
                                          (void *)(uint32)id_type,
                                          silc_hash_id_compare, 
                                          (void *)(uint32)id_type, 
-                                         silc_idcache_destructor, NULL);
+                                         silc_idcache_destructor, NULL, 
+                                         FALSE);
   cache->name_table = silc_hash_table_alloc(count, silc_hash_string, NULL,
                                            silc_hash_string_compare, NULL, 
-                                           NULL, NULL);
+                                           NULL, NULL, FALSE);
   cache->context_table = silc_hash_table_alloc(count, silc_hash_ptr, NULL,
-                                              NULL, NULL, NULL, NULL);
+                                              NULL, NULL, NULL, NULL, FALSE);
   cache->destructor = destructor;
   cache->type = id_type;
 
@@ -304,6 +305,7 @@ bool silc_idcache_purge(SilcIDCache cache)
 bool silc_idcache_purge_by_context(SilcIDCache cache, void *context)
 {
   SilcIDCacheEntry entry;
+  bool ret = FALSE;
 
   if (!silc_hash_table_find(cache->context_table, context, NULL, 
                            (void *)&entry))
@@ -313,7 +315,15 @@ bool silc_idcache_purge_by_context(SilcIDCache cache, void *context)
   if (cache->destructor)
     cache->destructor(cache, entry);
   
-  return silc_idcache_del(cache, entry);
+  if (entry->name)
+    ret = silc_hash_table_del_by_context(cache->name_table, entry->name, 
+                                        entry);
+  if (entry->context)
+    ret = silc_hash_table_del(cache->context_table, entry->context);
+  if (entry->id)
+    ret = silc_hash_table_del_by_context(cache->id_table, entry->id, entry);
+
+  return ret;
 }
 
 /* Callback that is called by the hash table routine when traversing