Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
wmem_tree.h
Go to the documentation of this file.
1
13#ifndef __WMEM_TREE_H__
14#define __WMEM_TREE_H__
15
16#include "wmem_core.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif /* __cplusplus */
21
36struct _wmem_tree_t;
37typedef struct _wmem_tree_t wmem_tree_t;
38
46WS_DLL_PUBLIC
49
69WS_DLL_PUBLIC
72
82WS_DLL_PUBLIC
83void
84wmem_tree_destroy(wmem_tree_t *tree, bool free_keys, bool free_values);
85
92WS_DLL_PUBLIC
93bool
95
102WS_DLL_PUBLIC
103unsigned
104wmem_tree_count(const wmem_tree_t* tree);
105
122WS_DLL_PUBLIC
123void
124wmem_tree_insert32(wmem_tree_t *tree, uint32_t key, void *data);
125
133WS_DLL_PUBLIC
134bool
135wmem_tree_contains32(const wmem_tree_t *tree, uint32_t key);
136
146WS_DLL_PUBLIC
147void *
148wmem_tree_lookup32(const wmem_tree_t *tree, uint32_t key);
149
160WS_DLL_PUBLIC
161void *
162wmem_tree_lookup32_le(const wmem_tree_t *tree, uint32_t key);
163
176WS_DLL_PUBLIC
177void *
178wmem_tree_lookup32_le_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key);
179
190WS_DLL_PUBLIC
191void *
192wmem_tree_lookup32_ge(const wmem_tree_t *tree, uint32_t key);
193
206WS_DLL_PUBLIC
207void *
208wmem_tree_lookup32_ge_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key);
209
221WS_DLL_PUBLIC
222void *
223wmem_tree_remove32(wmem_tree_t *tree, uint32_t key);
224
226#define WMEM_TREE_STRING_NOCASE 0x00000001
227
242WS_DLL_PUBLIC
243void
244wmem_tree_insert_string(wmem_tree_t *tree, const char* key, void *data,
245 uint32_t flags);
246
258WS_DLL_PUBLIC
259void *
260wmem_tree_lookup_string(const wmem_tree_t* tree, const char* key, uint32_t flags);
261
274WS_DLL_PUBLIC
275void *
276wmem_tree_remove_string(wmem_tree_t* tree, const char* key, uint32_t flags);
277
278typedef struct _wmem_tree_key_t {
279 uint32_t length;
280 uint32_t *key;
282
323WS_DLL_PUBLIC
324void
326
336WS_DLL_PUBLIC
337void *
339
355WS_DLL_PUBLIC
356void *
358
370typedef bool (*wmem_foreach_func)(const void *key, void *value, void *userdata);
371
372
378typedef void (*wmem_printer_func)(const void *data);
379
380
392WS_DLL_PUBLIC
393bool
395 void *user_data);
396
397
408WS_DLL_PUBLIC
409void
410wmem_print_tree(const wmem_tree_t *tree, wmem_printer_func key_printer, wmem_printer_func data_printer);
411
415#ifdef __cplusplus
416}
417#endif /* __cplusplus */
418
419#endif /* __WMEM_TREE_H__ */
420
421/*
422 * Editor modelines - https://www.wireshark.org/tools/modelines.html
423 *
424 * Local variables:
425 * c-basic-offset: 4
426 * tab-width: 8
427 * indent-tabs-mode: nil
428 * End:
429 *
430 * vi: set shiftwidth=4 tabstop=8 expandtab:
431 * :indentSize=4:tabSize=8:noTabs=true:
432 */
WS_DLL_PUBLIC wmem_tree_t * wmem_tree_new_autoreset(wmem_allocator_t *metadata_scope, wmem_allocator_t *data_scope)
Creates a tree with two allocator scopes.
Definition wmem_tree.c:399
WS_DLL_PUBLIC void wmem_tree_insert_string(wmem_tree_t *tree, const char *key, void *data, uint32_t flags)
Insert a new value under a string key.
Definition wmem_tree.c:919
WS_DLL_PUBLIC unsigned wmem_tree_count(const wmem_tree_t *tree)
Returns number of nodes in tree.
Definition wmem_tree.c:473
WS_DLL_PUBLIC void wmem_print_tree(const wmem_tree_t *tree, wmem_printer_func key_printer, wmem_printer_func data_printer)
Print the contents of a tree using optional key and data printer callbacks.
Definition wmem_tree.c:1146
WS_DLL_PUBLIC bool wmem_tree_is_empty(const wmem_tree_t *tree)
Returns true if the tree is empty (has no nodes).
Definition wmem_tree.c:459
WS_DLL_PUBLIC void * wmem_tree_lookup32_ge(const wmem_tree_t *tree, uint32_t key)
Look up a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:878
WS_DLL_PUBLIC bool wmem_tree_contains32(const wmem_tree_t *tree, uint32_t key)
Look up a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:665
WS_DLL_PUBLIC void wmem_tree_insert32(wmem_tree_t *tree, uint32_t key, void *data)
Insert a node indexed by a uint32_t key value.
Definition wmem_tree.c:660
void(* wmem_printer_func)(const void *data)
Function type to print key/data of nodes in wmem_print_tree_verbose.
Definition wmem_tree.h:378
WS_DLL_PUBLIC wmem_tree_t * wmem_tree_new(wmem_allocator_t *allocator)
Creates a tree with the given allocator scope. When the scope is emptied, the tree is fully destroyed...
Definition wmem_tree.c:360
WS_DLL_PUBLIC void * wmem_tree_lookup32_le_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key)
Look up a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:800
WS_DLL_PUBLIC void * wmem_tree_lookup32_array_le(const wmem_tree_t *tree, wmem_tree_key_t *key)
Look up a node in the tree indexed by a multi-part tree value.
Definition wmem_tree.c:1033
WS_DLL_PUBLIC void wmem_tree_insert32_array(wmem_tree_t *tree, wmem_tree_key_t *key, void *data)
Insert a node indexed by a sequence of uint32_t key values.
Definition wmem_tree.c:967
WS_DLL_PUBLIC void * wmem_tree_lookup32_ge_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key)
Look up a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:889
WS_DLL_PUBLIC void * wmem_tree_remove_string(wmem_tree_t *tree, const char *key, uint32_t flags)
Remove the value under a string key.
Definition wmem_tree.c:950
WS_DLL_PUBLIC void * wmem_tree_lookup_string(const wmem_tree_t *tree, const char *key, uint32_t flags)
Lookup the value under a string key.
Definition wmem_tree.c:936
WS_DLL_PUBLIC void * wmem_tree_lookup32(const wmem_tree_t *tree, uint32_t key)
Look up a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:713
WS_DLL_PUBLIC void * wmem_tree_lookup32_array(const wmem_tree_t *tree, wmem_tree_key_t *key)
Look up a node in the tree indexed by a sequence of uint32_t integer values.
Definition wmem_tree.c:1027
WS_DLL_PUBLIC void wmem_tree_destroy(wmem_tree_t *tree, bool free_keys, bool free_values)
Cleanup memory used by tree.
Definition wmem_tree.c:446
WS_DLL_PUBLIC void * wmem_tree_lookup32_le(const wmem_tree_t *tree, uint32_t key)
Look up a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:789
bool(* wmem_foreach_func)(const void *key, void *value, void *userdata)
Function type for processing one node of a tree during a traversal.
Definition wmem_tree.h:370
WS_DLL_PUBLIC void * wmem_tree_remove32(wmem_tree_t *tree, uint32_t key)
Remove a node in the tree indexed by a uint32_t integer value.
Definition wmem_tree.c:901
WS_DLL_PUBLIC bool wmem_tree_foreach(const wmem_tree_t *tree, wmem_foreach_func callback, void *user_data)
Inorder traversal (left/parent/right) of the tree.
Definition wmem_tree.c:1076
Definition wmem_allocator.h:27
Definition wmem_tree.h:278
uint32_t * key
Definition wmem_tree.h:280
uint32_t length
Definition wmem_tree.h:279
Definition wmem_tree-int.h:48