| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
wmem_array.h
Go to the documentation of this file.
1
11
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
21 extern "C" {
22#endif /* __cplusplus */
23
32
33 struct _wmem_array_t;
34
42 typedef struct _wmem_array_t wmem_array_t;
43
56WS_DLL_PUBLIC
57 wmem_array_t *
58 wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size,
59 unsigned alloc_count);
60
71WS_DLL_PUBLIC
72 wmem_array_t *
73 wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size);
74
84WS_DLL_PUBLIC
85 bool
86 wmem_array_grow(wmem_array_t *array, const unsigned to_add);
87
97WS_DLL_PUBLIC
98 void
99 wmem_array_set_null_terminator(wmem_array_t *array);
100
108WS_DLL_PUBLIC
109 void
110 wmem_array_bzero(wmem_array_t *array);
111
127WS_DLL_PUBLIC
128 bool
129 wmem_array_append(wmem_array_t *array, const void *in, unsigned count);
130
140#define wmem_array_append_one(ARRAY, VAL) \
141 wmem_array_append((ARRAY), &(VAL), 1)
142
154WS_DLL_PUBLIC
155 void *
156 wmem_array_index(const wmem_array_t *array, unsigned array_index);
157
170WS_DLL_PUBLIC
171 int
172 wmem_array_try_index(const wmem_array_t *array, unsigned array_index, void *val);
173
185WS_DLL_PUBLIC
186 void
187 wmem_array_sort(wmem_array_t *array, int (*compar)(const void*,const void*));
188
198WS_DLL_PUBLIC
199 void *
200 wmem_array_get_raw(const wmem_array_t *array);
201
211WS_DLL_PUBLIC
212 unsigned
213 wmem_array_get_count(const wmem_array_t *array);
214
224WS_DLL_PUBLIC
225 wmem_allocator_t*
226 wmem_array_get_allocator(const wmem_array_t* array);
227
243WS_DLL_PUBLIC
244 void *
245 wmem_array_finalize(wmem_array_t *array);
246
256WS_DLL_PUBLIC
257 void
258 wmem_destroy_array(wmem_array_t *array);
259
262
263#ifdef __cplusplus
264}
265#endif /* __cplusplus */
266
267#endif /* __WMEM_ARRAY_H__ */
268
269/*
270 * Editor modelines - https://www.wireshark.org/tools/modelines.html
271 *
272 * Local variables:
273 * c-basic-offset: 4
274 * tab-width: 8
275 * indent-tabs-mode: nil
276 * End:
277 *
278 * vi: set shiftwidth=4 tabstop=8 expandtab:
279 * :indentSize=4:tabSize=8:noTabs=true:
280 */
wmem_array_get_allocator
WS_DLL_PUBLIC wmem_allocator_t * wmem_array_get_allocator(const wmem_array_t *array)
Retrieve the memory allocator associated with a dynamic array.
Definition wmem_array.c:195
wmem_array_new
WS_DLL_PUBLIC wmem_array_t * wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size)
Create a new dynamically sized array with default initial capacity.
Definition wmem_array.c:63
wmem_destroy_array
WS_DLL_PUBLIC void wmem_destroy_array(wmem_array_t *array)
Destroy a dynamic array and free its associated memory.
Definition wmem_array.c:218
wmem_array_index
WS_DLL_PUBLIC void * wmem_array_index(const wmem_array_t *array, unsigned array_index)
Retrieve a pointer to an element in a dynamic array by index.
Definition wmem_array.c:158
wmem_array_bzero
WS_DLL_PUBLIC void wmem_array_bzero(wmem_array_t *array)
Zero out the contents of a dynamic array.
Definition wmem_array.c:137
wmem_array_get_count
WS_DLL_PUBLIC unsigned wmem_array_get_count(const wmem_array_t *array)
Get the number of elements currently stored in a dynamic array.
Definition wmem_array.c:186
wmem_array_get_raw
WS_DLL_PUBLIC void * wmem_array_get_raw(const wmem_array_t *array)
Retrieve a raw pointer to the internal buffer of a dynamic array.
Definition wmem_array.c:180
wmem_array_sized_new
WS_DLL_PUBLIC wmem_array_t * wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size, unsigned alloc_count)
Create a new dynamically sized array with a specified element size and initial capacity.
Definition wmem_array.c:43
wmem_array_try_index
WS_DLL_PUBLIC int wmem_array_try_index(const wmem_array_t *array, unsigned array_index, void *val)
Safely retrieve an element from a dynamic array by index.
Definition wmem_array.c:165
wmem_array_t
struct _wmem_array_t wmem_array_t
Opaque type representing a dynamically resizable array in the wmem system.
Definition wmem_array.h:42
wmem_array_sort
WS_DLL_PUBLIC void wmem_array_sort(wmem_array_t *array, int(*compar)(const void *, const void *))
Sort the elements of a dynamic array.
Definition wmem_array.c:174
wmem_array_set_null_terminator
WS_DLL_PUBLIC void wmem_array_set_null_terminator(wmem_array_t *array)
Set a null terminator at the end of a dynamic array.
Definition wmem_array.c:130
wmem_array_finalize
WS_DLL_PUBLIC void * wmem_array_finalize(wmem_array_t *array)
Finalize a dynamic array and retrieve its underlying buffer.
Definition wmem_array.c:204
wmem_array_append
WS_DLL_PUBLIC bool wmem_array_append(wmem_array_t *array, const void *in, unsigned count)
Append elements to a dynamic array.
Definition wmem_array.c:143
wmem_array_grow
WS_DLL_PUBLIC bool wmem_array_grow(wmem_array_t *array, const unsigned to_add)
Increase the capacity of a dynamic array by a specified number of elements.
Definition wmem_array.c:73
wmem_allocator_t
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
_wmem_array_t
Definition wmem_array.c:29
wmem_core.h