| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
wmem_tree.h
Go to the documentation of this file.
1
12
13#ifndef __WMEM_TREE_H__
14#define __WMEM_TREE_H__
15
16#include "wmem_core.h"
17
18#ifdef __cplusplus
19 extern "C" {
20#endif /* __cplusplus */
21
35
36 struct _wmem_tree_t;
37
49 typedef struct _wmem_tree_t wmem_tree_t;
50
58WS_DLL_PUBLIC
59 wmem_tree_t *
60 wmem_tree_new(wmem_allocator_t *allocator);
61
81WS_DLL_PUBLIC
82 wmem_tree_t *
83 wmem_tree_new_autoreset(wmem_allocator_t *metadata_scope, wmem_allocator_t *data_scope);
84
94WS_DLL_PUBLIC
95 void
96 wmem_tree_destroy(wmem_tree_t *tree, bool free_keys, bool free_values);
97
104WS_DLL_PUBLIC
105 bool
106 wmem_tree_is_empty(const wmem_tree_t *tree);
107
114WS_DLL_PUBLIC
115 unsigned
116 wmem_tree_count(const wmem_tree_t* tree);
117
134WS_DLL_PUBLIC
135 void
136 wmem_tree_insert32(wmem_tree_t *tree, uint32_t key, void *data);
137
145WS_DLL_PUBLIC
146 bool
147 wmem_tree_contains32(const wmem_tree_t *tree, uint32_t key);
148
158WS_DLL_PUBLIC
159 void *
160 wmem_tree_lookup32(const wmem_tree_t *tree, uint32_t key);
161
172WS_DLL_PUBLIC
173 void *
174 wmem_tree_lookup32_le(const wmem_tree_t *tree, uint32_t key);
175
188WS_DLL_PUBLIC
189 void *
190 wmem_tree_lookup32_le_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key);
191
202WS_DLL_PUBLIC
203 void *
204 wmem_tree_lookup32_ge(const wmem_tree_t *tree, uint32_t key);
205
218WS_DLL_PUBLIC
219 void *
220 wmem_tree_lookup32_ge_full(const wmem_tree_t *tree, uint32_t key, uint32_t *orig_key);
221
233WS_DLL_PUBLIC
234 void *
235 wmem_tree_remove32(wmem_tree_t *tree, uint32_t key);
236
238#define WMEM_TREE_STRING_NOCASE 0x00000001
239
254WS_DLL_PUBLIC
255 void
256 wmem_tree_insert_string(wmem_tree_t *tree, const char* key, void *data,
257 uint32_t flags);
258
270WS_DLL_PUBLIC
271 void *
272 wmem_tree_lookup_string(const wmem_tree_t* tree, const char* key, uint32_t flags);
273
286WS_DLL_PUBLIC
287 void *
288 wmem_tree_remove_string(wmem_tree_t* tree, const char* key, uint32_t flags);
289
297 typedef struct _wmem_tree_key_t {
298 uint32_t length;
299 uint32_t *key;
300} wmem_tree_key_t;
301
342WS_DLL_PUBLIC
343 void
344 wmem_tree_insert32_array(wmem_tree_t *tree, wmem_tree_key_t *key, void *data);
345
355WS_DLL_PUBLIC
356 void *
357 wmem_tree_lookup32_array(const wmem_tree_t *tree, wmem_tree_key_t *key);
358
374WS_DLL_PUBLIC
375 void *
376 wmem_tree_lookup32_array_le(const wmem_tree_t *tree, wmem_tree_key_t *key);
377
389 typedef bool (*wmem_foreach_func)(const void *key, void *value, void *userdata);
390
391
397 typedef void (*wmem_printer_func)(const void *data);
398
399
411WS_DLL_PUBLIC
412 bool
413 wmem_tree_foreach(const wmem_tree_t* tree, wmem_foreach_func callback,
414 void *user_data);
415
425WS_DLL_PUBLIC
426 wmem_allocator_t*
427 wmem_tree_get_data_scope(const wmem_tree_t* tree);
428
439WS_DLL_PUBLIC
440 void
441 wmem_print_tree(const wmem_tree_t *tree, wmem_printer_func key_printer, wmem_printer_func data_printer);
442
445
446#ifdef __cplusplus
447}
448#endif /* __cplusplus */
449
450#endif /* __WMEM_TREE_H__ */
451
452/*
453 * Editor modelines - https://www.wireshark.org/tools/modelines.html
454 *
455 * Local variables:
456 * c-basic-offset: 4
457 * tab-width: 8
458 * indent-tabs-mode: nil
459 * End:
460 *
461 * vi: set shiftwidth=4 tabstop=8 expandtab:
462 * :indentSize=4:tabSize=8:noTabs=true:
463 */
wmem_tree_new_autoreset
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
wmem_tree_insert_string
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
wmem_tree_count
WS_DLL_PUBLIC unsigned wmem_tree_count(const wmem_tree_t *tree)
Returns number of nodes in tree.
Definition wmem_tree.c:473
wmem_print_tree
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:1152
wmem_tree_is_empty
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
wmem_tree_lookup32_ge
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
wmem_tree_contains32
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
wmem_tree_insert32
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
wmem_printer_func
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
wmem_tree_new
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
wmem_tree_lookup32_le_full
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
wmem_tree_lookup32_array_le
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
wmem_tree_insert32_array
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
wmem_tree_lookup32_ge_full
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
wmem_tree_get_data_scope
WS_DLL_PUBLIC wmem_allocator_t * wmem_tree_get_data_scope(const wmem_tree_t *tree)
return the memory scope used by the data of the tree
Definition wmem_tree.c:1086
wmem_tree_remove_string
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
wmem_tree_lookup_string
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
wmem_tree_lookup32
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
wmem_tree_lookup32_array
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
wmem_tree_destroy
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
wmem_tree_key_t
struct _wmem_tree_key_t wmem_tree_key_t
Represents a key used in a wmem tree.
wmem_tree_lookup32_le
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
wmem_foreach_func
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
wmem_tree_remove32
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
wmem_tree_foreach
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
wmem_tree_t
struct _wmem_tree_t wmem_tree_t
Opaque type representing a red-black tree in the wmem system.
Definition wmem_tree.h:49
wmem_allocator_t
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
_wmem_tree_key_t
Represents a key used in a wmem tree.
Definition wmem_tree.h:297
_wmem_tree_key_t::key
uint32_t * key
Definition wmem_tree.h:299
_wmem_tree_key_t::length
uint32_t length
Definition wmem_tree.h:298
_wmem_tree_t
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
wmem_core.h