From: Pekka Riikonen Date: Tue, 24 Apr 2007 17:31:23 +0000 (+0000) Subject: silc_idcache_update now saves ID pointer if it wasn't present in X-Git-Tag: silc.toolkit.1.1.beta1~28 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=fcc066ee40b688943ab329089a964630b9456e86 silc_idcache_update now saves ID pointer if it wasn't present in the entry. --- diff --git a/lib/silcapputil/silcidcache.c b/lib/silcapputil/silcidcache.c index 7340414a..00237fb8 100644 --- a/lib/silcapputil/silcidcache.c +++ b/lib/silcapputil/silcidcache.c @@ -244,15 +244,19 @@ SilcBool silc_idcache_update(SilcIDCache cache, SilcIDCacheEntry entry, return FALSE; if (new_id) { - if (!silc_hash_table_del_by_context(cache->id_table, entry->id, entry)) - return FALSE; + if (entry->id) { + if (!silc_hash_table_del_by_context(cache->id_table, entry->id, entry)) + return FALSE; - if (cache->id_type == SILC_ID_CLIENT) - *(SilcClientID *)entry->id = *(SilcClientID *)new_id; - if (cache->id_type == SILC_ID_SERVER) - *(SilcServerID *)entry->id = *(SilcServerID *)new_id; - if (cache->id_type == SILC_ID_CHANNEL) - *(SilcChannelID *)entry->id = *(SilcChannelID *)new_id; + if (cache->id_type == SILC_ID_CLIENT) + *(SilcClientID *)entry->id = *(SilcClientID *)new_id; + if (cache->id_type == SILC_ID_SERVER) + *(SilcServerID *)entry->id = *(SilcServerID *)new_id; + if (cache->id_type == SILC_ID_CHANNEL) + *(SilcChannelID *)entry->id = *(SilcChannelID *)new_id; + } else { + entry->id = new_id; + } if (!silc_hash_table_add(cache->id_table, entry->id, entry)) return FALSE; diff --git a/lib/silcapputil/silcidcache.h b/lib/silcapputil/silcidcache.h index 05a009de..8d4278ab 100644 --- a/lib/silcapputil/silcidcache.h +++ b/lib/silcapputil/silcidcache.h @@ -208,7 +208,8 @@ SilcBool silc_idcache_del_by_context(SilcIDCache cache, void *context, * DESCRIPTION * * Updates cache `entry' with new values. If the `new_id' is non-NULL - * then the new value will be copied over the old value in the `entry'. + * then the new value will be copied over the old value in the `entry' + * unless the ID doesn't exist, when the `new_id' will be stored in `entry'. * 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