Wireshark  4.3.0
The Wireshark network protocol analyzer
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
21 extern "C" {
22 #endif /* __cplusplus */
23 
33 struct _wmem_array_t;
34 
35 typedef struct _wmem_array_t wmem_array_t;
36 
37 WS_DLL_PUBLIC
39 wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size,
40  unsigned alloc_count)
41 G_GNUC_MALLOC;
42 
43 WS_DLL_PUBLIC
45 wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size)
46 G_GNUC_MALLOC;
47 
48 WS_DLL_PUBLIC
49 void
50 wmem_array_grow(wmem_array_t *array, const unsigned to_add);
51 
52 WS_DLL_PUBLIC
53 void
54 wmem_array_set_null_terminator(wmem_array_t *array);
55 
56 WS_DLL_PUBLIC
57 void
58 wmem_array_bzero(wmem_array_t *array);
59 
60 WS_DLL_PUBLIC
61 void
62 wmem_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 
67 WS_DLL_PUBLIC
68 void *
69 wmem_array_index(wmem_array_t *array, unsigned array_index);
70 
71 WS_DLL_PUBLIC
72 int
73 wmem_array_try_index(wmem_array_t *array, unsigned array_index, void *val);
74 
75 WS_DLL_PUBLIC
76 void
77 wmem_array_sort(wmem_array_t *array, int (*compar)(const void*,const void*));
78 
79 WS_DLL_PUBLIC
80 void *
81 wmem_array_get_raw(wmem_array_t *array);
82 
83 WS_DLL_PUBLIC
84 unsigned
85 wmem_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  */
93 WS_DLL_PUBLIC
94 void *
95 wmem_array_finalize(wmem_array_t *array);
96 
97 WS_DLL_PUBLIC
98 void
99 wmem_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