Add wmem_map_steal
Mimic functionality of g_hash_table_steal Change-Id: Iaf4aeef951b60934569143b2d119f782aeefe380 Reviewed-on: https://code.wireshark.org/review/20038 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
cd38552259
commit
e3128d9806
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue