Add wmem_map_get_keys.
Mimic functionality of g_hash_table_get_keys Change-Id: I7702854ed771a5b3bf7ea5295a67c42f0f477cdf Reviewed-on: https://code.wireshark.org/review/20039 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
e3128d9806
commit
f8b69fb349
|
@ -1788,6 +1788,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
wmem_list_remove_frame@Base 1.12.0~rc1
|
||||
wmem_list_tail@Base 1.12.0~rc1
|
||||
wmem_map_foreach@Base 2.1.0
|
||||
wmem_map_get_keys@Base 2.3.0
|
||||
wmem_map_insert@Base 1.12.0~rc1
|
||||
wmem_map_lookup@Base 1.12.0~rc1
|
||||
wmem_map_new@Base 1.12.0~rc1
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include "wmem_core.h"
|
||||
#include "wmem_list.h"
|
||||
#include "wmem_map.h"
|
||||
#include "wmem_map_int.h"
|
||||
#include "wmem_user_cb.h"
|
||||
|
@ -322,6 +323,29 @@ wmem_map_steal(wmem_map_t *map, const void *key)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
wmem_list_t*
|
||||
wmem_map_get_keys(wmem_allocator_t *list_allocator, wmem_map_t *map)
|
||||
{
|
||||
size_t capacity, i;
|
||||
wmem_map_item_t *cur;
|
||||
wmem_list_t* list = wmem_list_new(list_allocator);
|
||||
|
||||
if (map->table != NULL) {
|
||||
capacity = CAPACITY(map);
|
||||
|
||||
/* copy all the elements into the list over from table */
|
||||
for (i=0; i<capacity; i++) {
|
||||
cur = map->table[i];
|
||||
while (cur) {
|
||||
wmem_list_prepend(list, (void*)cur->key);
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void
|
||||
wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, gpointer user_data)
|
||||
{
|
||||
|
|
|
@ -131,6 +131,16 @@ WS_DLL_PUBLIC
|
|||
gboolean
|
||||
wmem_map_steal(wmem_map_t *map, const void *key);
|
||||
|
||||
/** Retrieves a list of keys inside the map
|
||||
*
|
||||
* @param list_allocator The allocator scope for the returned list.
|
||||
* @param map The map to extract keys from
|
||||
* @return list of keys in the map
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
wmem_list_t*
|
||||
wmem_map_get_keys(wmem_allocator_t *list_allocator, wmem_map_t *map);
|
||||
|
||||
/** 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