[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35486 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35486 - in gnunet/src: include util |
Date: |
Mon, 30 Mar 2015 21:46:18 +0200 |
Author: grothoff
Date: 2015-03-30 21:46:17 +0200 (Mon, 30 Mar 2015)
New Revision: 35486
Modified:
gnunet/src/include/gnunet_container_lib.h
gnunet/src/include/gnunet_datastore_service.h
gnunet/src/util/container_multihashmap.c
Log:
add multihashmap_clear to API
Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h 2015-03-30 12:36:33 UTC (rev
35485)
+++ gnunet/src/include/gnunet_container_lib.h 2015-03-30 19:46:17 UTC (rev
35486)
@@ -699,6 +699,18 @@
/**
* @ingroup hashmap
+ * Remove all entries from the map.
+ * Note that the values would not be "freed".
+ *
+ * @param map the map
+ * @return number of values removed
+ */
+unsigned int
+GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap
*map);
+
+
+/**
+ * @ingroup hashmap
* Check if the map contains any value under the given
* key (including values that are NULL).
*
@@ -757,8 +769,7 @@
* @return the number of key value pairs
*/
unsigned int
-GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap
- *map);
+GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap
*map);
/**
@@ -772,8 +783,7 @@
* #GNUNET_SYSERR if it aborted iteration
*/
int
-GNUNET_CONTAINER_multihashmap_iterate (const struct
- GNUNET_CONTAINER_MultiHashMap *map,
+GNUNET_CONTAINER_multihashmap_iterate (const struct
GNUNET_CONTAINER_MultiHashMap *map,
GNUNET_CONTAINER_HashMapIterator it,
void *it_cls);
Modified: gnunet/src/include/gnunet_datastore_service.h
===================================================================
--- gnunet/src/include/gnunet_datastore_service.h 2015-03-30 12:36:33 UTC
(rev 35485)
+++ gnunet/src/include/gnunet_datastore_service.h 2015-03-30 19:46:17 UTC
(rev 35486)
@@ -207,7 +207,8 @@
* (or rather, will already have been invoked)
*/
struct GNUNET_DATASTORE_QueueEntry *
-GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid,
+GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h,
+ uint64_t uid,
uint32_t priority,
struct GNUNET_TIME_Absolute expiration,
unsigned int queue_priority,
@@ -239,8 +240,10 @@
*/
struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
- const struct GNUNET_HashCode * key, size_t size,
- const void *data, unsigned int queue_priority,
+ const struct GNUNET_HashCode *key,
+ size_t size,
+ const void *data,
+ unsigned int queue_priority,
unsigned int max_queue_size,
struct GNUNET_TIME_Relative timeout,
GNUNET_DATASTORE_ContinuationWithStatus cont,
@@ -261,14 +264,16 @@
* @param uid unique identifier for the datum;
* maybe 0 if no unique identifier is available
*/
-typedef void (*GNUNET_DATASTORE_DatumProcessor) (void *cls,
- const struct GNUNET_HashCode
*key,
- size_t size, const void *data,
- enum GNUNET_BLOCK_Type type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute
expiration,
- uint64_t uid);
+typedef void
+(*GNUNET_DATASTORE_DatumProcessor) (void *cls,
+ const struct GNUNET_HashCode *key,
+ size_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration,
+ uint64_t uid);
/**
@@ -293,13 +298,15 @@
* cancel
*/
struct GNUNET_DATASTORE_QueueEntry *
-GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, uint64_t offset,
+GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h,
+ uint64_t offset,
const struct GNUNET_HashCode *key,
enum GNUNET_BLOCK_Type type,
unsigned int queue_priority,
unsigned int max_queue_size,
struct GNUNET_TIME_Relative timeout,
- GNUNET_DATASTORE_DatumProcessor proc, void
*proc_cls);
+ GNUNET_DATASTORE_DatumProcessor proc,
+ void *proc_cls);
/**
@@ -352,7 +359,7 @@
* @param proc function to call on a random value; it
* will be called once with a value (if available)
* and always once with a value of NULL.
- * @param proc_cls closure for proc
+ * @param proc_cls closure for @a proc
* @return NULL if the entry was not queued, otherwise a handle that can be
used to
* cancel
*/
Modified: gnunet/src/util/container_multihashmap.c
===================================================================
--- gnunet/src/util/container_multihashmap.c 2015-03-30 12:36:33 UTC (rev
35485)
+++ gnunet/src/util/container_multihashmap.c 2015-03-30 19:46:17 UTC (rev
35486)
@@ -275,8 +275,8 @@
* key-value pairs with value NULL
*/
void *
-GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap
- *map, const struct GNUNET_HashCode *key)
+GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap
*map,
+ const struct GNUNET_HashCode *key)
{
union MapEntry me;
@@ -446,8 +446,8 @@
* @return number of values removed
*/
int
-GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
- *map, const struct GNUNET_HashCode
*key)
+GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
*map,
+ const struct GNUNET_HashCode *key)
{
union MapEntry me;
unsigned int i;
@@ -523,6 +523,49 @@
/**
+ * Callback used to remove all entries from the map.
+ *
+ * @param cls the `struct GNUNET_CONTAINER_MultiHashMap`
+ * @param key the key
+ * @param value the value
+ * @return #GNUNET_OK (continue to iterate)
+ */
+static int
+remove_all (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ struct GNUNET_CONTAINER_MultiHashMap *map = cls;
+
+ GNUNET_CONTAINER_multihashmap_remove (map,
+ key,
+ value);
+ return GNUNET_OK;
+}
+
+
+/**
+ * @ingroup hashmap
+ * Remove all entries from the map.
+ * Note that the values would not be "freed".
+ *
+ * @param map the map
+ * @return number of values removed
+ */
+unsigned int
+GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map)
+{
+ unsigned int ret;
+
+ ret = map->size;
+ GNUNET_CONTAINER_multihashmap_iterate (map,
+ &remove_all,
+ map);
+ return ret;
+}
+
+
+/**
* Check if the map contains any value under the given
* key (including values that are NULL).
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35486 - in gnunet/src: include util,
gnunet <=