Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
wmem_map.h
Go to the documentation of this file.
1
12#ifndef __WMEM_MAP_H__
13#define __WMEM_MAP_H__
14
15#include <glib.h>
16
17#include "wmem_core.h"
18#include "wmem_list.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
37struct _wmem_map_t;
38typedef struct _wmem_map_t wmem_map_t;
39
63WS_DLL_PUBLIC
66 GHashFunc hash_func, GEqualFunc eql_func)
67G_GNUC_MALLOC;
68
86WS_DLL_PUBLIC
89 GHashFunc hash_func, GEqualFunc eql_func)
90G_GNUC_MALLOC;
91
100WS_DLL_PUBLIC
101void *
102wmem_map_insert(wmem_map_t *map, const void *key, void *value);
103
111WS_DLL_PUBLIC
112bool
113wmem_map_contains(const wmem_map_t *map, const void *key);
114
122WS_DLL_PUBLIC
123void *
124wmem_map_lookup(const wmem_map_t *map, const void *key);
125
136WS_DLL_PUBLIC
137bool
138wmem_map_lookup_extended(const wmem_map_t *map, const void *key, const void **orig_key, void **value);
139
148WS_DLL_PUBLIC
149void *
150wmem_map_remove(wmem_map_t *map, const void *key);
151
160WS_DLL_PUBLIC
161bool
162wmem_map_steal(wmem_map_t *map, const void *key);
163
171WS_DLL_PUBLIC
173wmem_map_get_keys(wmem_allocator_t *list_allocator, const wmem_map_t *map);
174
186WS_DLL_PUBLIC
187void
188wmem_map_foreach(const wmem_map_t *map, GHFunc foreach_func, void * user_data);
189
203WS_DLL_PUBLIC
204unsigned
205wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void * user_data);
206
220WS_DLL_PUBLIC
221void *
222wmem_map_find(const wmem_map_t *map, GHRFunc foreach_func, void * user_data);
223
230WS_DLL_PUBLIC
231unsigned
232wmem_map_size(const wmem_map_t *map);
233
249WS_DLL_PUBLIC
250size_t
251wmem_map_reserve(wmem_map_t *map, uint64_t capacity);
252
270WS_DLL_PUBLIC
271void
272wmem_map_destroy(wmem_map_t *map, bool free_keys, bool free_values);
273
287WS_DLL_PUBLIC
288uint32_t
289wmem_strong_hash(const uint8_t *buf, const size_t len);
290
304WS_DLL_PUBLIC
305unsigned
306wmem_str_hash(const void *key);
307
321WS_DLL_PUBLIC
322unsigned
323wmem_int64_hash(const void *key);
324
338WS_DLL_PUBLIC
339unsigned
340wmem_double_hash(const void *key);
341
345#ifdef __cplusplus
346}
347#endif /* __cplusplus */
348
349#endif /* __WMEM_MAP_H__ */
350
351/*
352 * Editor modelines - https://www.wireshark.org/tools/modelines.html
353 *
354 * Local variables:
355 * c-basic-offset: 4
356 * tab-width: 8
357 * indent-tabs-mode: nil
358 * End:
359 *
360 * vi: set shiftwidth=4 tabstop=8 expandtab:
361 * :indentSize=4:tabSize=8:noTabs=true:
362 */
WS_DLL_PUBLIC wmem_map_t * wmem_map_new(wmem_allocator_t *allocator, GHashFunc hash_func, GEqualFunc eql_func) G_GNUC_MALLOC
Creates a map with the given allocator scope.
Definition wmem_map.c:139
WS_DLL_PUBLIC unsigned wmem_int64_hash(const void *key)
Secure hash function for 64-bit integer keys using wmem_strong_hash.
Definition wmem_map.c:669
WS_DLL_PUBLIC void * wmem_map_remove(wmem_map_t *map, const void *key)
Remove a value from the map. If no value is stored at that key, nothing happens.
Definition wmem_map.c:424
WS_DLL_PUBLIC unsigned wmem_map_size(const wmem_map_t *map)
Return the number of elements in the map.
Definition wmem_map.c:584
WS_DLL_PUBLIC void wmem_map_foreach(const wmem_map_t *map, GHFunc foreach_func, void *user_data)
Run a function against all key/value pairs in the map.
Definition wmem_map.c:511
WS_DLL_PUBLIC void * wmem_map_find(const wmem_map_t *map, GHRFunc foreach_func, void *user_data)
Run a function against all key/value pairs in the map until the function returns true,...
Definition wmem_map.c:531
WS_DLL_PUBLIC unsigned wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void *user_data)
Run a function against all key/value pairs in the map. If the function returns true,...
Definition wmem_map.c:555
WS_DLL_PUBLIC unsigned wmem_double_hash(const void *key)
Secure hash function for double-precision floating-point keys using wmem_strong_hash.
Definition wmem_map.c:675
WS_DLL_PUBLIC wmem_list_t * wmem_map_get_keys(wmem_allocator_t *list_allocator, const wmem_map_t *map)
Retrieves a list of keys inside the map.
Definition wmem_map.c:488
WS_DLL_PUBLIC unsigned wmem_str_hash(const void *key)
Secure hash function for string keys using wmem_strong_hash.
Definition wmem_map.c:658
WS_DLL_PUBLIC uint32_t wmem_strong_hash(const uint8_t *buf, const size_t len)
Compute a strong hash value for an arbitrary sequence of bytes.
Definition wmem_map.c:618
WS_DLL_PUBLIC bool wmem_map_steal(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 k...
Definition wmem_map.c:457
WS_DLL_PUBLIC bool wmem_map_contains(const wmem_map_t *map, const void *key)
Check if a value is in the map.
Definition wmem_map.c:343
WS_DLL_PUBLIC void * wmem_map_insert(wmem_map_t *map, const void *key, void *value)
Inserts a value into the map.
Definition wmem_map.c:293
WS_DLL_PUBLIC bool wmem_map_lookup_extended(const wmem_map_t *map, const void *key, const void **orig_key, void **value)
Lookup a value in the map, returning the key, value, and a boolean which is true if the key is found.
Definition wmem_map.c:393
WS_DLL_PUBLIC size_t wmem_map_reserve(wmem_map_t *map, uint64_t capacity)
Ensure that a certain number of elements can be stored in the wmem_map without having to grow the int...
Definition wmem_map.c:590
WS_DLL_PUBLIC void * wmem_map_lookup(const wmem_map_t *map, const void *key)
Lookup a value in the map.
Definition wmem_map.c:368
WS_DLL_PUBLIC wmem_map_t * wmem_map_new_autoreset(wmem_allocator_t *metadata_scope, wmem_allocator_t *data_scope, GHashFunc hash_func, GEqualFunc eql_func) G_GNUC_MALLOC
Creates a map with two allocator scopes.
Definition wmem_map.c:188
WS_DLL_PUBLIC void wmem_map_destroy(wmem_map_t *map, bool free_keys, bool free_values)
Cleanup memory used by the map instead of waiting for the allocator pool to be freed or destroyed.
Definition wmem_map.c:267
Definition wmem_allocator.h:27
Definition wmem_list.c:23
Definition wmem_map.c:60