diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-05-14 13:32:13 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-05-14 13:32:13 +0000 |
commit | 4b1be5f17f2f9132d3b6e44d0f438af49c51b090 (patch) | |
tree | 02bc7cfccb9d5bcf1bda3cc458cf286bac6b2d8f | |
parent | 5a8c980e27163987553d4754dddb7902bcfd0f92 (diff) | |
download | gnunet-4b1be5f17f2f9132d3b6e44d0f438af49c51b090.tar.gz gnunet-4b1be5f17f2f9132d3b6e44d0f438af49c51b090.zip |
removed local function
-rw-r--r-- | src/lockmanager/lockmanager_api.c | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/src/lockmanager/lockmanager_api.c b/src/lockmanager/lockmanager_api.c index a6757d538..661064455 100644 --- a/src/lockmanager/lockmanager_api.c +++ b/src/lockmanager/lockmanager_api.c | |||
@@ -102,6 +102,28 @@ struct GNUNET_LOCKMANAGER_LockingRequest | |||
102 | 102 | ||
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Structure for matching a lock | ||
106 | */ | ||
107 | struct LockMatch | ||
108 | { | ||
109 | /** | ||
110 | * The matched LockingRequest entry; Should be NULL if no entry is found | ||
111 | */ | ||
112 | struct GNUNET_LOCKMANAGER_LockingRequest *matched_entry; | ||
113 | |||
114 | /** | ||
115 | * The locking domain name of the lock | ||
116 | */ | ||
117 | const char *domain; | ||
118 | |||
119 | /** | ||
120 | * The lock number | ||
121 | */ | ||
122 | uint32_t lock; | ||
123 | }; | ||
124 | |||
125 | |||
126 | /** | ||
105 | * Get the key for the given lock in the 'lock_map'. | 127 | * Get the key for the given lock in the 'lock_map'. |
106 | * | 128 | * |
107 | * @param domain_name | 129 | * @param domain_name |
@@ -124,6 +146,31 @@ get_key (const char *domain_name, | |||
124 | 146 | ||
125 | 147 | ||
126 | /** | 148 | /** |
149 | * Hashmap iterator for matching a lock | ||
150 | * | ||
151 | * @param cls the LockMatch structure | ||
152 | * @param key current key code | ||
153 | * @param value value in the hash map (struct GNUNET_LOCKMANAGER_LockingRequest) | ||
154 | * @return GNUNET_YES if we should continue to | ||
155 | * iterate, | ||
156 | * GNUNET_NO if not. | ||
157 | */ | ||
158 | static int | ||
159 | match_iterator (void *cls, const GNUNET_HashCode *key, void *value) | ||
160 | { | ||
161 | struct LockMatch *match = cls; | ||
162 | struct GNUNET_LOCKMANAGER_LockingRequest *lr = value; | ||
163 | |||
164 | if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) ) | ||
165 | { | ||
166 | match->matched_entry = lr; | ||
167 | return GNUNET_NO; | ||
168 | } | ||
169 | return GNUNET_YES; | ||
170 | } | ||
171 | |||
172 | |||
173 | /** | ||
127 | * Function to find a LockingRequest associated with the given domain and lock | 174 | * Function to find a LockingRequest associated with the given domain and lock |
128 | * attributes in the map | 175 | * attributes in the map |
129 | * | 176 | * |
@@ -138,27 +185,18 @@ hashmap_find_lockingrequest (const struct GNUNET_CONTAINER_MultiHashMap *map, | |||
138 | const char *domain, | 185 | const char *domain, |
139 | uint32_t lock) | 186 | uint32_t lock) |
140 | { | 187 | { |
141 | struct GNUNET_LOCKMANAGER_LockingRequest *lr; | ||
142 | struct GNUNET_HashCode hash; | 188 | struct GNUNET_HashCode hash; |
143 | int match_found; | 189 | struct LockMatch lock_match; |
144 | 190 | ||
145 | int match_iterator (void *cls, const GNUNET_HashCode *key, void *value) | 191 | lock_match.matched_entry = NULL; |
146 | { | 192 | lock_match.domain = domain; |
147 | lr = value; | 193 | lock_match.lock = lock; |
148 | if ( (lock == lr->lock) && (0 == strcmp (domain, lr->domain)) ) | ||
149 | { | ||
150 | match_found = GNUNET_YES; | ||
151 | return GNUNET_NO; | ||
152 | } | ||
153 | return GNUNET_YES; | ||
154 | } | ||
155 | get_key (domain, lock, &hash); | 194 | get_key (domain, lock, &hash); |
156 | match_found = GNUNET_NO; | ||
157 | GNUNET_CONTAINER_multihashmap_get_multiple (map, | 195 | GNUNET_CONTAINER_multihashmap_get_multiple (map, |
158 | &hash, | 196 | &hash, |
159 | &match_iterator, | 197 | &match_iterator, |
160 | NULL); | 198 | &lock_match); |
161 | return (GNUNET_YES == match_found) ? lr : NULL; | 199 | return lock_match.matched_entry; |
162 | } | 200 | } |
163 | 201 | ||
164 | 202 | ||