From 6eb2fcd520b47ecb9e8f9f4fb090f4da0736eefa Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Mon, 14 May 2012 13:45:34 +0000 Subject: [PATCH] -removed local function --- src/lockmanager/gnunet-service-lockmanager.c | 71 +++++++++++++++----- src/lockmanager/lockmanager_api.c | 10 +-- 2 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/lockmanager/gnunet-service-lockmanager.c b/src/lockmanager/gnunet-service-lockmanager.c index 974c14be1..18a5202a2 100644 --- a/src/lockmanager/gnunet-service-lockmanager.c +++ b/src/lockmanager/gnunet-service-lockmanager.c @@ -158,6 +158,28 @@ struct ClientList }; +/** + * Structure for matching a lock + */ +struct LockMatch +{ + /** + * The matched LockingRequest entry; Should be NULL if no entry is found + */ + struct Lock *matched_entry; + + /** + * The locking domain name of the lock + */ + const char *domain_name; + + /** + * The lock number + */ + uint32_t lock_num; +}; + + /** * Map of lock-keys to the 'struct LockList' entry for the key. */ @@ -196,6 +218,32 @@ get_key (const char *domain_name, } +/** + * Hashmap iterator for matching a lock + * + * @param cls the LockMatch structure + * @param key current key code + * @param value value in the hash map (struct Lock) + * @return GNUNET_YES if we should continue to + * iterate, + * GNUNET_NO if not. + */ +static int +match_iterator (void *cls, const GNUNET_HashCode *key, void *value) +{ + struct LockMatch *match = cls; + struct Lock *lock = value; + + if ( (match->lock_num == lock->lock_num) + && (0 == strcmp (match->domain_name, lock->domain_name)) ) + { + match->matched_entry = lock; + return GNUNET_NO; + } + return GNUNET_YES; +} + + /** * Function to search for a lock in the global lock hashmap * @@ -208,27 +256,18 @@ find_lock (const char *domain_name, const uint32_t lock_num) { - struct Lock *matched_lock; + struct LockMatch match; struct GNUNET_HashCode key; - matched_lock = NULL; - int match_lock (void *cls, - const GNUNET_HashCode *key, - void *value) - { - matched_lock = value; - if ((lock_num == matched_lock->lock_num) - && (0 == strcmp (domain_name, matched_lock->domain_name))) - return GNUNET_NO; - matched_lock = NULL; - return GNUNET_YES; - } + match.lock_num = lock_num; + match.domain_name = domain_name; + match.matched_entry = NULL; get_key (domain_name, lock_num, &key); GNUNET_CONTAINER_multihashmap_get_multiple (lock_map, &key, - &match_lock, - NULL); - return matched_lock; + &match_iterator, + &match); + return match.matched_entry; } diff --git a/src/lockmanager/lockmanager_api.c b/src/lockmanager/lockmanager_api.c index 661064455..53f5365e4 100644 --- a/src/lockmanager/lockmanager_api.c +++ b/src/lockmanager/lockmanager_api.c @@ -104,7 +104,7 @@ struct GNUNET_LOCKMANAGER_LockingRequest /** * Structure for matching a lock */ -struct LockMatch +struct LockingRequestMatch { /** * The matched LockingRequest entry; Should be NULL if no entry is found @@ -146,9 +146,9 @@ get_key (const char *domain_name, /** - * Hashmap iterator for matching a lock + * Hashmap iterator for matching a LockingRequest * - * @param cls the LockMatch structure + * @param cls the LockingRequestMatch structure * @param key current key code * @param value value in the hash map (struct GNUNET_LOCKMANAGER_LockingRequest) * @return GNUNET_YES if we should continue to @@ -158,7 +158,7 @@ get_key (const char *domain_name, static int match_iterator (void *cls, const GNUNET_HashCode *key, void *value) { - struct LockMatch *match = cls; + struct LockingRequestMatch *match = cls; struct GNUNET_LOCKMANAGER_LockingRequest *lr = value; if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) ) @@ -186,7 +186,7 @@ hashmap_find_lockingrequest (const struct GNUNET_CONTAINER_MultiHashMap *map, uint32_t lock) { struct GNUNET_HashCode hash; - struct LockMatch lock_match; + struct LockingRequestMatch lock_match; lock_match.matched_entry = NULL; lock_match.domain = domain; -- 2.25.1