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);
75
93WS_DLL_PUBLIC
96 GHashFunc hash_func, GEqualFunc eql_func);
97
106WS_DLL_PUBLIC
107void *
108wmem_map_insert(wmem_map_t *map, const void *key, void *value);
109
117WS_DLL_PUBLIC
118bool
119wmem_map_contains(const wmem_map_t *map, const void *key);
120
128WS_DLL_PUBLIC
129void *
130wmem_map_lookup(const wmem_map_t *map, const void *key);
131
142WS_DLL_PUBLIC
143bool
144wmem_map_lookup_extended(const wmem_map_t *map, const void *key, const void **orig_key, void **value);
145
154WS_DLL_PUBLIC
155void *
156wmem_map_remove(wmem_map_t *map, const void *key);
157
166WS_DLL_PUBLIC
167bool
168wmem_map_steal(wmem_map_t *map, const void *key);
169
177WS_DLL_PUBLIC
179wmem_map_get_keys(wmem_allocator_t *list_allocator, const wmem_map_t *map);
180
192WS_DLL_PUBLIC
193void
194wmem_map_foreach(const wmem_map_t *map, GHFunc foreach_func, void * user_data);
195
209WS_DLL_PUBLIC
210unsigned
211wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void * user_data);
212
226WS_DLL_PUBLIC
227void *
228wmem_map_find(const wmem_map_t *map, GHRFunc foreach_func, void * user_data);
229
236WS_DLL_PUBLIC
237unsigned
238wmem_map_size(const wmem_map_t *map);
239
256WS_DLL_PUBLIC
257size_t
258wmem_map_reserve(wmem_map_t *map, uint64_t capacity);
259
277WS_DLL_PUBLIC
278void
279wmem_map_destroy(wmem_map_t *map, bool free_keys, bool free_values);
280
294WS_DLL_PUBLIC
295uint32_t
296wmem_strong_hash(const uint8_t *buf, const size_t len);
297
311WS_DLL_PUBLIC
312unsigned
313wmem_str_hash(const void *key);
314
328WS_DLL_PUBLIC
329unsigned
330wmem_int64_hash(const void *key);
331
345WS_DLL_PUBLIC
346unsigned
347wmem_double_hash(const void *key);
348
352#ifdef __cplusplus
353}
354#endif /* __cplusplus */
355
356#endif /* __WMEM_MAP_H__ */
357
358/*
359 * Editor modelines - https://www.wireshark.org/tools/modelines.html
360 *
361 * Local variables:
362 * c-basic-offset: 4
363 * tab-width: 8
364 * indent-tabs-mode: nil
365 * End:
366 *
367 * vi: set shiftwidth=4 tabstop=8 expandtab:
368 * :indentSize=4:tabSize=8:noTabs=true:
369 */
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_map_t * wmem_map_new_autoreset(wmem_allocator_t *metadata_scope, wmem_allocator_t *data_scope, GHashFunc hash_func, GEqualFunc eql_func)
Creates a map with two allocator scopes.
Definition wmem_map.c:188
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 wmem_map_t * wmem_map_new(wmem_allocator_t *allocator, GHashFunc hash_func, GEqualFunc eql_func)
Creates a map with the given allocator scope.
Definition wmem_map.c:139
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 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