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;
37
50
58WS_DLL_PUBLIC
61
81WS_DLL_PUBLIC
84
94WS_DLL_PUBLIC
95void
96wmem_tree_destroy(wmem_tree_t *tree, bool free_keys, bool free_values);
97
104WS_DLL_PUBLIC
105bool
107
114WS_DLL_PUBLIC
115unsigned
116wmem_tree_count(const wmem_tree_t* tree);
117
134WS_DLL_PUBLIC
135void
136wmem_tree_insert32(wmem_tree_t *tree, uint32_t key, void *data);
137
145WS_DLL_PUBLIC
146bool
147wmem_tree_contains32(const wmem_tree_t *tree, uint32_t key);
148
158WS_DLL_PUBLIC
159void *
160wmem_tree_lookup32(const wmem_tree_t *tree, uint32_t key);
161
172WS_DLL_PUBLIC
173void *
174wmem_tree_lookup32_le(const wmem_tree_t *tree, uint32_t key);
175
188WS_DLL_PUBLIC
189void *
190wmem_tree_lookup32_le_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key);
191
202WS_DLL_PUBLIC
203void *
204wmem_tree_lookup32_ge(const wmem_tree_t *tree, uint32_t key);
205
218WS_DLL_PUBLIC
219void *
220wmem_tree_lookup32_ge_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key);
221
233WS_DLL_PUBLIC
234void *
235wmem_tree_remove32(wmem_tree_t *tree, uint32_t key);
236
238#define WMEM_TREE_STRING_NOCASE 0x00000001
239
254WS_DLL_PUBLIC
255void
256wmem_tree_insert_string(wmem_tree_t *tree, const char* key, void *data,
257 uint32_t flags);
258
270WS_DLL_PUBLIC
271void *
272wmem_tree_lookup_string(const wmem_tree_t* tree, const char* key, uint32_t flags);
273
286WS_DLL_PUBLIC
287void *
288wmem_tree_remove_string(wmem_tree_t* tree, const char* key, uint32_t flags);
289
297typedef struct _wmem_tree_key_t {
298 uint32_t length;
299 uint32_t *key;
301
342WS_DLL_PUBLIC
343void
345
355WS_DLL_PUBLIC
356void *
358
374WS_DLL_PUBLIC
375void *
377
389typedef bool (*wmem_foreach_func)(const void *key, void *value, void *userdata);
390
391
397typedef void (*wmem_printer_func)(const void *data);
398
399
411WS_DLL_PUBLIC
412bool
414 void *user_data);
415
416
427WS_DLL_PUBLIC
428void
429wmem_print_tree(const wmem_tree_t *tree, wmem_printer_func key_printer, wmem_printer_func data_printer);
430
434#ifdef __cplusplus
435}
436#endif /* __cplusplus */
437
438#endif /* __WMEM_TREE_H__ */
439
440/*
441 * Editor modelines - https://www.wireshark.org/tools/modelines.html
442 *
443 * Local variables:
444 * c-basic-offset: 4
445 * tab-width: 8
446 * indent-tabs-mode: nil
447 * End:
448 *
449 * vi: set shiftwidth=4 tabstop=8 expandtab:
450 * :indentSize=4:tabSize=8:noTabs=true:
451 */
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:397
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
struct _wmem_tree_key_t wmem_tree_key_t
Represents a key used in a wmem tree.
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:389
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
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Represents a key used in a wmem tree.
Definition wmem_tree.h:297
uint32_t * key
Definition wmem_tree.h:299
uint32_t length
Definition wmem_tree.h:298
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81