From 18ae0cdc5483a2a0246b51fc63de0f0998c32f81 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 9 Nov 2006 16:10:40 +0000 Subject: [PATCH] Added free_old_name param to silc_idcache_update. --- lib/silcapputil/silcidcache.c | 5 ++++- lib/silcapputil/silcidcache.h | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/silcapputil/silcidcache.c b/lib/silcapputil/silcidcache.c index 05959388..93364caf 100644 --- a/lib/silcapputil/silcidcache.c +++ b/lib/silcapputil/silcidcache.c @@ -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)) diff --git a/lib/silcapputil/silcidcache.h b/lib/silcapputil/silcidcache.h index 3e092b8a..aed03d85 100644 --- a/lib/silcapputil/silcidcache.h +++ b/lib/silcapputil/silcidcache.h @@ -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 * -- 2.24.0