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;
38
46typedef struct _wmem_map_t wmem_map_t;
47
71WS_DLL_PUBLIC
74 GHashFunc hash_func, GEqualFunc eql_func)
75G_GNUC_MALLOC;
76
94WS_DLL_PUBLIC
97 GHashFunc hash_func, GEqualFunc eql_func)
98G_GNUC_MALLOC;
99
108WS_DLL_PUBLIC
109void *
110wmem_map_insert(wmem_map_t *map, const void *key, void *value);
111
119WS_DLL_PUBLIC
120bool
121wmem_map_contains(const wmem_map_t *map, const void *key);
122
130WS_DLL_PUBLIC
131void *
132wmem_map_lookup(const wmem_map_t *map, const void *key);
133
144WS_DLL_PUBLIC
145bool
146wmem_map_lookup_extended(const wmem_map_t *map, const void *key, const void **orig_key, void **value);
147
156WS_DLL_PUBLIC
157void *
158wmem_map_remove(wmem_map_t *map, const void *key);
159
168WS_DLL_PUBLIC
169bool
170wmem_map_steal(wmem_map_t *map, const void *key);
171
179WS_DLL_PUBLIC
181wmem_map_get_keys(wmem_allocator_t *list_allocator, const wmem_map_t *map);
182
194WS_DLL_PUBLIC
195void
196wmem_map_foreach(const wmem_map_t *map, GHFunc foreach_func, void * user_data);
197
211WS_DLL_PUBLIC
212unsigned
213wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void * user_data);
214
228WS_DLL_PUBLIC
229void *
230wmem_map_find(const wmem_map_t *map, GHRFunc foreach_func, void * user_data);
231
238WS_DLL_PUBLIC
239unsigned
240wmem_map_size(const wmem_map_t *map);
241
258WS_DLL_PUBLIC
259size_t
260wmem_map_reserve(wmem_map_t *map, uint64_t capacity);
261
279WS_DLL_PUBLIC
280void
281wmem_map_destroy(wmem_map_t *map, bool free_keys, bool free_values);
282
296WS_DLL_PUBLIC
297uint32_t
298wmem_strong_hash(const uint8_t *buf, const size_t len);
299
313WS_DLL_PUBLIC
314unsigned
315wmem_str_hash(const void *key);
316
330WS_DLL_PUBLIC
331unsigned
332wmem_int64_hash(const void *key);
333
347WS_DLL_PUBLIC
348unsigned
349wmem_double_hash(const void *key);
350
354#ifdef __cplusplus
355}
356#endif /* __cplusplus */
357
358#endif /* __WMEM_MAP_H__ */
359
360/*
361 * Editor modelines - https://www.wireshark.org/tools/modelines.html
362 *
363 * Local variables:
364 * c-basic-offset: 4
365 * tab-width: 8
366 * indent-tabs-mode: nil
367 * End:
368 *
369 * vi: set shiftwidth=4 tabstop=8 expandtab:
370 * :indentSize=4:tabSize=8:noTabs=true:
371 */
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
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition wmem_list.c:23
Definition wmem_map.c:60