[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21476 - gnunet/src/lockmanager
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21476 - gnunet/src/lockmanager |
Date: |
Mon, 14 May 2012 15:32:13 +0200 |
Author: harsha
Date: 2012-05-14 15:32:13 +0200 (Mon, 14 May 2012)
New Revision: 21476
Modified:
gnunet/src/lockmanager/lockmanager_api.c
Log:
removed local function
Modified: gnunet/src/lockmanager/lockmanager_api.c
===================================================================
--- gnunet/src/lockmanager/lockmanager_api.c 2012-05-14 13:04:48 UTC (rev
21475)
+++ gnunet/src/lockmanager/lockmanager_api.c 2012-05-14 13:32:13 UTC (rev
21476)
@@ -102,6 +102,28 @@
/**
+ * Structure for matching a lock
+ */
+struct LockMatch
+{
+ /**
+ * The matched LockingRequest entry; Should be NULL if no entry is found
+ */
+ struct GNUNET_LOCKMANAGER_LockingRequest *matched_entry;
+
+ /**
+ * The locking domain name of the lock
+ */
+ const char *domain;
+
+ /**
+ * The lock number
+ */
+ uint32_t lock;
+};
+
+
+/**
* Get the key for the given lock in the 'lock_map'.
*
* @param domain_name
@@ -124,6 +146,31 @@
/**
+ * Hashmap iterator for matching a lock
+ *
+ * @param cls the LockMatch 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
+ * iterate,
+ * GNUNET_NO if not.
+ */
+static int
+match_iterator (void *cls, const GNUNET_HashCode *key, void *value)
+{
+ struct LockMatch *match = cls;
+ struct GNUNET_LOCKMANAGER_LockingRequest *lr = value;
+
+ if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) )
+ {
+ match->matched_entry = lr;
+ return GNUNET_NO;
+ }
+ return GNUNET_YES;
+}
+
+
+/**
* Function to find a LockingRequest associated with the given domain and lock
* attributes in the map
*
@@ -138,27 +185,18 @@
const char *domain,
uint32_t lock)
{
- struct GNUNET_LOCKMANAGER_LockingRequest *lr;
struct GNUNET_HashCode hash;
- int match_found;
+ struct LockMatch lock_match;
- int match_iterator (void *cls, const GNUNET_HashCode *key, void *value)
- {
- lr = value;
- if ( (lock == lr->lock) && (0 == strcmp (domain, lr->domain)) )
- {
- match_found = GNUNET_YES;
- return GNUNET_NO;
- }
- return GNUNET_YES;
- }
+ lock_match.matched_entry = NULL;
+ lock_match.domain = domain;
+ lock_match.lock = lock;
get_key (domain, lock, &hash);
- match_found = GNUNET_NO;
GNUNET_CONTAINER_multihashmap_get_multiple (map,
&hash,
&match_iterator,
- NULL);
- return (GNUNET_YES == match_found) ? lr : NULL;
+ &lock_match);
+ return lock_match.matched_entry;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21476 - gnunet/src/lockmanager,
gnunet <=