X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcidcache.c;h=62fb5af0a1b3a7694477d5fe3e1738874ea3b2c1;hp=da86f7437a5cc51409c6662ebd4c9772b6ec371b;hb=816a5b080c797c0db47b7b274a85646343c3466e;hpb=c257b555225193e54d85daf541d29578b3c93882 diff --git a/lib/silccore/silcidcache.c b/lib/silccore/silcidcache.c index da86f743..62fb5af0 100644 --- a/lib/silccore/silcidcache.c +++ b/lib/silccore/silcidcache.c @@ -67,6 +67,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 +103,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 +125,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 +347,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 +388,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);