Added free_old_name param to silc_idcache_update.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 9 Nov 2006 16:10:40 +0000 (16:10 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 9 Nov 2006 16:10:40 +0000 (16:10 +0000)
lib/silcapputil/silcidcache.c
lib/silcapputil/silcidcache.h

index 05959388faab0d6204b7a724a959e0f855d450ce..93364caf6ca97e04647a35ac4a813910c99bf370 100644 (file)
@@ -223,7 +223,8 @@ SilcBool silc_idcache_del_by_context(SilcIDCache cache, void *context,
 
 SilcBool silc_idcache_update(SilcIDCache cache, SilcIDCacheEntry entry,
                             void *old_id, void *new_id,
-                            char *old_name, char *new_name)
+                            char *old_name, char *new_name,
+                            SilcBool free_old_name)
 {
   if (old_id && new_id) {
     if (!silc_hash_table_del_by_context(cache->id_table, old_id, entry))
@@ -244,6 +245,8 @@ SilcBool silc_idcache_update(SilcIDCache cache, SilcIDCacheEntry entry,
     if (!silc_hash_table_del_by_context(cache->name_table, old_name, entry))
       return FALSE;
 
+    if (free_old_name)
+      silc_free(entry->name);
     entry->name = new_name;
 
     if (!silc_hash_table_add(cache->name_table, entry->name, entry))
index 3e092b8a7b3dd1d86f64ca2f6f00034a711f8b27..aed03d859d15121d0c29e3d8d16d21b1082255b0 100644 (file)
@@ -206,7 +206,8 @@ SilcBool silc_idcache_del_by_context(SilcIDCache cache, void *context,
  *
  *    SilcBool silc_idcache_update(SilcIDCache cache, SilcIDCacheEntry entry,
  *                                 void *old_id, void *new_id,
- *                                 char *old_name, char *new_name);
+ *                                 char *old_name, char *new_name,
+ *                                 SilcBool free_old_name);
  *
  * DESCRIPTION
  *
@@ -215,12 +216,14 @@ SilcBool silc_idcache_del_by_context(SilcIDCache cache, void *context,
  *    If the `new_name' is non-NULL then the `entry' will be updated with
  *    `new_name'.  The caller is responsible of freeing the old name if it
  *    was updated with new one.  The old ID value does not need to be freed
- *    as the new value is copied over the old value.
+ *    as the new value is copied over the old value.  If the `free_old_name'
+ *    is TRUE the library will free the old name from the entry.
  *
  ***/
 SilcBool silc_idcache_update(SilcIDCache cache, SilcIDCacheEntry entry,
                             void *old_id, void *new_id,
-                            char *old_name, char *new_name);
+                            char *old_name, char *new_name,
+                            SilcBool free_old_name);
 
 /****f* silcapputil/SilcIDCacheAPI/silc_idcache_get_all
  *