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
35typedef struct _wmem_array_t wmem_array_t;
36
49WS_DLL_PUBLIC
51wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size,
52 unsigned alloc_count)
53G_GNUC_MALLOC;
54
65WS_DLL_PUBLIC
67wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size)
68G_GNUC_MALLOC;
69
79WS_DLL_PUBLIC
80void
81wmem_array_grow(wmem_array_t *array, const unsigned to_add);
82
92WS_DLL_PUBLIC
93void
95
103WS_DLL_PUBLIC
104void
106
117WS_DLL_PUBLIC
118void
119wmem_array_append(wmem_array_t *array, const void *in, unsigned count);
120
121#define wmem_array_append_one(ARRAY, VAL) \
122 wmem_array_append((ARRAY), &(VAL), 1)
123
135WS_DLL_PUBLIC
136void *
137wmem_array_index(const wmem_array_t *array, unsigned array_index);
138
151WS_DLL_PUBLIC
152int
153wmem_array_try_index(const wmem_array_t *array, unsigned array_index, void *val);
154
166WS_DLL_PUBLIC
167void
168wmem_array_sort(wmem_array_t *array, int (*compar)(const void*,const void*));
169
179WS_DLL_PUBLIC
180void *
181wmem_array_get_raw(const wmem_array_t *array);
182
192WS_DLL_PUBLIC
193unsigned
195
205WS_DLL_PUBLIC
208
224WS_DLL_PUBLIC
225void *
227
237WS_DLL_PUBLIC
238void
240
244#ifdef __cplusplus
245}
246#endif /* __cplusplus */
247
248#endif /* __WMEM_ARRAY_H__ */
249
250/*
251 * Editor modelines - https://www.wireshark.org/tools/modelines.html
252 *
253 * Local variables:
254 * c-basic-offset: 4
255 * tab-width: 8
256 * indent-tabs-mode: nil
257 * End:
258 *
259 * vi: set shiftwidth=4 tabstop=8 expandtab:
260 * :indentSize=4:tabSize=8:noTabs=true:
261 */
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
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
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
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
WS_DLL_PUBLIC void wmem_array_bzero(wmem_array_t *array)
Zero out the contents of a dynamic array.
Definition wmem_array.c:109
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
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
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
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
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
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
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
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
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
Definition wmem_allocator.h:27
Definition wmem_array.c:27