Wireshark 4.5.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
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
87/* Truncates the underlying array to the elements contained within
88 * (including null terminator if set), frees the wmem_array_t
89 * structure, and returns a pointer to the raw array. The wmem_array_t
90 * struct cannot be used after this is called. This is for when you are
91 * done adding elements to the array but still need the underlying array.
92 */
93WS_DLL_PUBLIC
94void *
95wmem_array_finalize(wmem_array_t *array);
96
97WS_DLL_PUBLIC
98void
99wmem_destroy_array(wmem_array_t *array);
100
104#ifdef __cplusplus
105}
106#endif /* __cplusplus */
107
108#endif /* __WMEM_ARRAY_H__ */
109
110/*
111 * Editor modelines - https://www.wireshark.org/tools/modelines.html
112 *
113 * Local variables:
114 * c-basic-offset: 4
115 * tab-width: 8
116 * indent-tabs-mode: nil
117 * End:
118 *
119 * vi: set shiftwidth=4 tabstop=8 expandtab:
120 * :indentSize=4:tabSize=8:noTabs=true:
121 */
Definition wmem_allocator.h:27
Definition wmem_array.c:27