aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/libwireshark0.symbols1
-rw-r--r--epan/wmem/wmem_map.c29
-rw-r--r--epan/wmem/wmem_map.h11
3 files changed, 41 insertions, 0 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index c400c2a000..d055fba235 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -1794,6 +1794,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
wmem_map_new_autoreset@Base 2.3.0
wmem_map_remove@Base 1.12.0~rc1
wmem_map_size@Base 2.1.0
+ wmem_map_steal@Base 2.3.0
wmem_memdup@Base 1.12.0~rc1
wmem_packet_scope@Base 1.9.1
wmem_realloc@Base 1.9.1
diff --git a/epan/wmem/wmem_map.c b/epan/wmem/wmem_map.c
index 5d1a781809..f1529a02a6 100644
--- a/epan/wmem/wmem_map.c
+++ b/epan/wmem/wmem_map.c
@@ -293,6 +293,35 @@ wmem_map_remove(wmem_map_t *map, const void *key)
return NULL;
}
+gboolean
+wmem_map_steal(wmem_map_t *map, const void *key)
+{
+ wmem_map_item_t **item, *tmp;
+
+ /* Make sure we have a table */
+ if (map->table == NULL) {
+ return FALSE;
+ }
+
+ /* get a pointer to the slot */
+ item = &(map->table[HASH(map, key)]);
+
+ /* check the items in that slot */
+ while (*item) {
+ if (map->eql_func(key, (*item)->key)) {
+ /* found it */
+ tmp = (*item);
+ (*item) = tmp->next;
+ map->count--;
+ return TRUE;
+ }
+ item = &((*item)->next);
+ }
+
+ /* didn't find it */
+ return FALSE;
+}
+
void
wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, gpointer user_data)
{
diff --git a/epan/wmem/wmem_map.h b/epan/wmem/wmem_map.h
index 1ea4cf3350..8c3e90972d 100644
--- a/epan/wmem/wmem_map.h
+++ b/epan/wmem/wmem_map.h
@@ -120,6 +120,17 @@ WS_DLL_PUBLIC
void *
wmem_map_remove(wmem_map_t *map, const void *key);
+/** Remove a key and value from the map but does not destroy (free) them. If no
+ * value is stored at that key, nothing happens.
+ *
+ * @param map The map to remove from.
+ * @param key The key of the value to remove.
+ * @return TRUE if key is found FALSE if not.
+ */
+WS_DLL_PUBLIC
+gboolean
+wmem_map_steal(wmem_map_t *map, const void *key);
+
/** Run a function against all key/value pairs in the map. The order
* of the calls is unpredictable, since it is based on the internal
* storage of data.