Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
wmem_array.h
Go to the documentation of this file.
1
12#ifndef __WMEM_ARRAY_H__
13#define __WMEM_ARRAY_H__
14
15#include <string.h>
16#include <glib.h>
17
18#include "wmem_core.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
33struct _wmem_array_t;
34
35typedef struct _wmem_array_t wmem_array_t;
36
37WS_DLL_PUBLIC
39wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size,
40 unsigned alloc_count)
41G_GNUC_MALLOC;
42
43WS_DLL_PUBLIC
45wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size)
46G_GNUC_MALLOC;
47
48WS_DLL_PUBLIC
49void
50wmem_array_grow(wmem_array_t *array, const unsigned to_add);
51
52WS_DLL_PUBLIC
53void
54wmem_array_set_null_terminator(wmem_array_t *array);
55
56WS_DLL_PUBLIC
57void
58wmem_array_bzero(wmem_array_t *array);
59
60WS_DLL_PUBLIC
61void
62wmem_array_append(wmem_array_t *array, const void *in, unsigned count);
63
64#define wmem_array_append_one(ARRAY, VAL) \
65 wmem_array_append((ARRAY), &(VAL), 1)
66
67WS_DLL_PUBLIC
68void *
69wmem_array_index(wmem_array_t *array, unsigned array_index);
70
71WS_DLL_PUBLIC
72int
73wmem_array_try_index(wmem_array_t *array, unsigned array_index, void *val);
74
75WS_DLL_PUBLIC
76void
77wmem_array_sort(wmem_array_t *array, int (*compar)(const void*,const void*));
78
79WS_DLL_PUBLIC
80void *
81wmem_array_get_raw(wmem_array_t *array);
82
83WS_DLL_PUBLIC
84unsigned
85wmem_array_get_count(wmem_array_t *array);
86
87WS_DLL_PUBLIC
89wmem_array_get_allocator(wmem_array_t* array);
90
91/* Truncates the underlying array to the elements contained within
92 * (including null terminator if set), frees the wmem_array_t
93 * structure, and returns a pointer to the raw array. The wmem_array_t
94 * struct cannot be used after this is called. This is for when you are
95 * done adding elements to the array but still need the underlying array.
96 */
97WS_DLL_PUBLIC
98void *
99wmem_array_finalize(wmem_array_t *array);
100
101WS_DLL_PUBLIC
102void
103wmem_destroy_array(wmem_array_t *array);
104
108#ifdef __cplusplus
109}
110#endif /* __cplusplus */
111
112#endif /* __WMEM_ARRAY_H__ */
113
114/*
115 * Editor modelines - https://www.wireshark.org/tools/modelines.html
116 *
117 * Local variables:
118 * c-basic-offset: 4
119 * tab-width: 8
120 * indent-tabs-mode: nil
121 * End:
122 *
123 * vi: set shiftwidth=4 tabstop=8 expandtab:
124 * :indentSize=4:tabSize=8:noTabs=true:
125 */
Definition wmem_allocator.h:27
Definition wmem_array.c:27