Changed SilcIDCache API to have context in destructor.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 19 Apr 2005 09:02:21 +0000 (09:02 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 19 Apr 2005 09:02:21 +0000 (09:02 +0000)
CHANGES
lib/configure.ad
lib/silcclient/client.c
lib/silccore/silcidcache.c
lib/silccore/silcidcache.h

diff --git a/CHANGES b/CHANGES
index 2ebf810f8dca4e78ef571ea89376c3cc49b9033a..2fe70b2987a54572c999b04cb83dd9768e939a67 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Tue Apr 19 11:57:35 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
+
+       * Added context to the SilcIDCache destructor.  Affected
+         files are lib/silccore/silcidcache.[ch],
+         lib/silcclient/client.c and silcd/server.c.
+
 Mon Apr 18 09:53:28 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
 
        * Added pkg-config check to configure.
index f52573cb16079cf4c91ae8844d75f8e282dd18c5..ff9e2a3c99acf4d1da9d4a8d7f7fd8112e01808e 100644 (file)
@@ -51,7 +51,7 @@ SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcclient"
 # Do the releases and library versioning according to following rules:
 #
 #  - If any code has changed in library, increment [LIB]_REVISION
-#  - If functions were added, set [LIB]_REVISION to 0
+#  - If functions were added, removed or changed, set [LIB]_REVISION to 0
 #  - If functions were added, removed or changed, increment [LIB]_CURRENT
 #  - If functions were added, increment [LIB]_AGE
 #  - If functions were removed, set [LIB]_AGE to 0
@@ -68,14 +68,14 @@ SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcclient"
 LIB_BASE_VERSION=1.0
 
 # libsilc versions
-LIBSILC_CURRENT=4              # prev = 3
+LIBSILC_CURRENT=5              # prev = 4
 LIBSILC_REVISION=0             # prev = 0
-LIBSILC_AGE=3                  # prev = 2
+LIBSILC_AGE=3                  # prev = 3
 
 # libsilcclient versions
-LIBSILCCLIENT_CURRENT=4                # prev = 3
+LIBSILCCLIENT_CURRENT=4                # prev = 4
 LIBSILCCLIENT_REVISION=0       # prev = 0
-LIBSILCCLIENT_AGE=3            # prev = 2
+LIBSILCCLIENT_AGE=3            # prev = 3
 
 # Substitute the version numbers
 AC_SUBST(LIB_BASE_VERSION)
index d4546038895c4c10d7c0c85f9b1d234e72f609e5..6119198166981a6afcf073c910356326384c4bcd 100644 (file)
@@ -254,11 +254,11 @@ silc_client_add_connection(SilcClient client,
   conn->remote_port = port;
   conn->context = context;
   conn->internal->client_cache =
-    silc_idcache_alloc(0, SILC_ID_CLIENT, NULL, FALSE, TRUE);
+    silc_idcache_alloc(0, SILC_ID_CLIENT, NULL, NULL, FALSE, TRUE);
   conn->internal->channel_cache = silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL,
-                                                    FALSE, TRUE);
+                                                    NULL, FALSE, TRUE);
   conn->internal->server_cache = silc_idcache_alloc(0, SILC_ID_SERVER, NULL,
-                                                   FALSE, TRUE);
+                                                   NULL, FALSE, TRUE);
   conn->internal->pending_commands = silc_dlist_init();
   conn->internal->ftp_sessions = silc_dlist_init();
 
index da86f7437a5cc51409c6662ebd4c9772b6ec371b..62fb5af0a1b3a7694477d5fe3e1738874ea3b2c1 100644 (file)
@@ -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);
index 69c5290f1bdb8a639d2a74c0f56f6b8a9bbca88a..b5612d391e9e3267b30b15add1fff8dd529a0919 100644 (file)
@@ -111,7 +111,8 @@ typedef struct SilcIDCacheListStruct *SilcIDCacheList;
  * SYNOPSIS
  *
  *    typedef void (*SilcIDCacheDestructor)(SilcIDCache cache,
- *                                          SilcIDCacheEntry entry);
+ *                                          SilcIDCacheEntry entry,
+ *                                          void *context);
  *
  * DESCRIPTION
  *
@@ -122,7 +123,8 @@ typedef struct SilcIDCacheListStruct *SilcIDCacheList;
  *
  ***/
 typedef void (*SilcIDCacheDestructor)(SilcIDCache cache,
-                                     SilcIDCacheEntry entry);
+                                     SilcIDCacheEntry entry,
+                                     void *context);
 
 #define SILC_ID_CACHE_EXPIRE 3600
 #define SILC_ID_CACHE_EXPIRE_DEF (time(NULL) + SILC_ID_CACHE_EXPIRE)
@@ -134,7 +136,9 @@ typedef void (*SilcIDCacheDestructor)(SilcIDCache cache,
  * SYNOPSIS
  *
  *    SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type,
- *                                   SilcIDCacheDestructor destructor);
+ *                                   SilcIDCacheDestructor destructor,
+ *                                   void *destructor_context,
+ *                                   bool delete_id, bool delete_name);
  *
  * DESCRIPTION
  *
@@ -150,6 +154,7 @@ typedef void (*SilcIDCacheDestructor)(SilcIDCache cache,
  ***/
 SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type,
                               SilcIDCacheDestructor destructor,
+                              void *destructor_context,
                               bool delete_id, bool delete_name);
 
 /****f* silccore/SilcIDCacheAPI/silc_idcache_free