aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2014-02-12 10:22:35 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2014-02-12 10:22:35 +0000
commit98e59e7eb847f1e1f2c17a3be29fea9d23266fff (patch)
treefe05963c4ddee55f2fd1be0c25cc5369ce287f96 /src/testbed
parent4ba1042bb27cde309c059841b94aac6b2353fe21 (diff)
downloadgnunet-98e59e7eb847f1e1f2c17a3be29fea9d23266fff.tar.gz
gnunet-98e59e7eb847f1e1f2c17a3be29fea9d23266fff.zip
- Cleanup cache items after removing from the hashmap.
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c
index 070aeefa5..32f63f3e3 100644
--- a/src/testbed/gnunet-service-testbed_cache.c
+++ b/src/testbed/gnunet-service-testbed_cache.c
@@ -112,6 +112,20 @@ cache_lookup (unsigned int peer_id)
112 112
113 113
114/** 114/**
115 * Free the resources occupied by a cache entry
116 *
117 * @param entry the cache entry to free
118 */
119static void
120free_entry (struct CacheEntry *entry)
121{
122 GNUNET_CONTAINER_DLL_remove (cache_head, cache_tail, entry);
123 GNUNET_free_non_null (entry->hello);
124 GNUNET_free (entry);
125}
126
127
128/**
115 * Creates a new cache entry and then puts it into the cache's hashtable. 129 * Creates a new cache entry and then puts it into the cache's hashtable.
116 * 130 *
117 * @param peer_id the index of the peer to tag the newly created entry 131 * @param peer_id the index of the peer to tag the newly created entry
@@ -131,6 +145,7 @@ add_entry (unsigned int peer_id)
131 GNUNET_CONTAINER_multihashmap32_remove (cache, (uint32_t) 145 GNUNET_CONTAINER_multihashmap32_remove (cache, (uint32_t)
132 entry->peer_id, 146 entry->peer_id,
133 entry)); 147 entry));
148 free_entry (entry);
134 } 149 }
135 entry = GNUNET_new (struct CacheEntry); 150 entry = GNUNET_new (struct CacheEntry);
136 entry->peer_id = peer_id; 151 entry->peer_id = peer_id;
@@ -162,8 +177,7 @@ cache_clear_iterator (void *cls, uint32_t key, void *value)
162 GNUNET_assert (NULL != entry); 177 GNUNET_assert (NULL != entry);
163 GNUNET_assert (GNUNET_YES == 178 GNUNET_assert (GNUNET_YES ==
164 GNUNET_CONTAINER_multihashmap32_remove (cache, key, value)); 179 GNUNET_CONTAINER_multihashmap32_remove (cache, key, value));
165 GNUNET_free_non_null (entry->hello); 180 free_entry (entry);
166 GNUNET_free (entry);
167 return GNUNET_YES; 181 return GNUNET_YES;
168} 182}
169 183