| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
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
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)
60G_GNUC_MALLOC;
61
72WS_DLL_PUBLIC
73 wmem_array_t *
74 wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size)
75G_GNUC_MALLOC;
76
86WS_DLL_PUBLIC
87void
88 wmem_array_grow(wmem_array_t *array, const unsigned to_add);
89
99WS_DLL_PUBLIC
100void
101 wmem_array_set_null_terminator(wmem_array_t *array);
102
110WS_DLL_PUBLIC
111void
112 wmem_array_bzero(wmem_array_t *array);
113
124WS_DLL_PUBLIC
125void
126 wmem_array_append(wmem_array_t *array, const void *in, unsigned count);
127
137#define wmem_array_append_one(ARRAY, VAL) \
138 wmem_array_append((ARRAY), &(VAL), 1)
139
151WS_DLL_PUBLIC
152void *
153 wmem_array_index(const wmem_array_t *array, unsigned array_index);
154
167WS_DLL_PUBLIC
168int
169 wmem_array_try_index(const wmem_array_t *array, unsigned array_index, void *val);
170
182WS_DLL_PUBLIC
183void
184 wmem_array_sort(wmem_array_t *array, int (*compar)(const void*,const void*));
185
195WS_DLL_PUBLIC
196void *
197 wmem_array_get_raw(const wmem_array_t *array);
198
208WS_DLL_PUBLIC
209unsigned
210 wmem_array_get_count(const wmem_array_t *array);
211
221WS_DLL_PUBLIC
222 wmem_allocator_t*
223 wmem_array_get_allocator(const wmem_array_t* array);
224
240WS_DLL_PUBLIC
241void *
242 wmem_array_finalize(wmem_array_t *array);
243
253WS_DLL_PUBLIC
254void
255 wmem_destroy_array(wmem_array_t *array);
256
260#ifdef __cplusplus
261}
262#endif /* __cplusplus */
263
264#endif /* __WMEM_ARRAY_H__ */
265
266/*
267 * Editor modelines - https://www.wireshark.org/tools/modelines.html
268 *
269 * Local variables:
270 * c-basic-offset: 4
271 * tab-width: 8
272 * indent-tabs-mode: nil
273 * End:
274 *
275 * vi: set shiftwidth=4 tabstop=8 expandtab:
276 * :indentSize=4:tabSize=8:noTabs=true:
277 */
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:165
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) G_GNUC_MALLOC
Create a new dynamically sized array with a specified element size and initial capacity.
Definition wmem_array.c:41
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:188
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:128
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:109
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:156
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:150
wmem_array_grow
WS_DLL_PUBLIC void 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:71
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:135
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:144
wmem_array_new
WS_DLL_PUBLIC wmem_array_t * wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size) G_GNUC_MALLOC
Create a new dynamically sized array with default initial capacity.
Definition wmem_array.c:61
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:102
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:174
wmem_array_append
WS_DLL_PUBLIC void wmem_array_append(wmem_array_t *array, const void *in, unsigned count)
Append elements to a dynamic array.
Definition wmem_array.c:115
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
_wmem_array_t
Definition wmem_array.c:27
wmem_core.h