/*
This file is part of GNUnet.
- (C) 2008--2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2008--2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
}
+/**
+ * Free the resources occupied by a cache entry
+ *
+ * @param entry the cache entry to free
+ */
+static void
+free_entry (struct CacheEntry *entry)
+{
+ GNUNET_CONTAINER_DLL_remove (cache_head, cache_tail, entry);
+ GNUNET_free_non_null (entry->hello);
+ GNUNET_free (entry);
+}
+
+
/**
* Creates a new cache entry and then puts it into the cache's hashtable.
*
add_entry (unsigned int peer_id)
{
struct CacheEntry *entry;
-
+
GNUNET_assert (NULL != cache);
if (cache_size == GNUNET_CONTAINER_multihashmap32_size (cache))
{
GNUNET_CONTAINER_multihashmap32_remove (cache, (uint32_t)
entry->peer_id,
entry));
+ free_entry (entry);
}
entry = GNUNET_new (struct CacheEntry);
entry->peer_id = peer_id;
GNUNET_assert (NULL != entry);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap32_remove (cache, key, value));
- GNUNET_free_non_null (entry->hello);
- GNUNET_free (entry);
+ free_entry (entry);
return GNUNET_YES;
}