Merged silc_1_0_branch to trunk.
[silc.git] / lib / silccore / silcidcache.c
index da86f7437a5cc51409c6662ebd4c9772b6ec371b..a2a279cc4567b48abfc8f98439e655b49b47cb04 100644 (file)
@@ -8,8 +8,7 @@
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
+  the Free Software Foundation; version 2 of the License.
 
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -67,6 +66,7 @@ struct SilcIDCacheStruct {
   SilcHashTable name_table;
   SilcHashTable context_table;
   SilcIDCacheDestructor destructor;
+  void *context;
   SilcIdType type;
   unsigned int delete_id : 1;
   unsigned int delete_name : 1;
@@ -102,6 +102,7 @@ struct SilcIDCacheListStruct {
 
 SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type,
                               SilcIDCacheDestructor destructor,
+                              void *destructor_context,
                               bool delete_id, bool delete_name)
 {
   SilcIDCache cache;
@@ -123,6 +124,7 @@ SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type,
   cache->context_table = silc_hash_table_alloc(count, silc_hash_ptr, NULL,
                                               NULL, NULL, NULL, NULL, TRUE);
   cache->destructor = destructor;
+  cache->context = destructor_context;
   cache->type = id_type;
   cache->delete_id = delete_id;
   cache->delete_name = delete_name;
@@ -344,7 +346,7 @@ static void silc_idcache_purge_foreach(void *key, void *context,
     if (ret == TRUE) {
       /* Call the destructor */
       if (cache->destructor)
-       cache->destructor(cache, c);
+       cache->destructor(cache, c, cache->context);
 
       /* Free the entry, it has been deleted from the hash tables */
       silc_idcache_destructor(NULL, c, NULL);
@@ -385,7 +387,7 @@ bool silc_idcache_purge_by_context(SilcIDCache cache, void *context)
   if (ret == TRUE) {
     /* Call the destructor */
     if (cache->destructor)
-      cache->destructor(cache, c);
+      cache->destructor(cache, c, cache->context);
 
     /* Free the entry, it has been deleted from the hash tables */
     silc_idcache_destructor(NULL, c, NULL);