Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / wsutil / wmem / wmem_array.h
blobe813232da925788a22c0a278a9f46ba18a5bfd9e
1 /** @file
2 * Definitions for the Wireshark Memory Manager Array
3 * Copyright 2013, Evan Huus <eapache@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __WMEM_ARRAY_H__
13 #define __WMEM_ARRAY_H__
15 #include <string.h>
16 #include <glib.h>
18 #include "wmem_core.h"
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
24 /** @addtogroup wmem
25 * @{
26 * @defgroup wmem-array Array
28 * A resizable array implementation on top of wmem.
30 * @{
33 struct _wmem_array_t;
35 typedef struct _wmem_array_t wmem_array_t;
37 WS_DLL_PUBLIC
38 wmem_array_t *
39 wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size,
40 unsigned alloc_count)
41 G_GNUC_MALLOC;
43 WS_DLL_PUBLIC
44 wmem_array_t *
45 wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size)
46 G_GNUC_MALLOC;
48 WS_DLL_PUBLIC
49 void
50 wmem_array_grow(wmem_array_t *array, const unsigned to_add);
52 WS_DLL_PUBLIC
53 void
54 wmem_array_set_null_terminator(wmem_array_t *array);
56 WS_DLL_PUBLIC
57 void
58 wmem_array_bzero(wmem_array_t *array);
60 WS_DLL_PUBLIC
61 void
62 wmem_array_append(wmem_array_t *array, const void *in, unsigned count);
64 #define wmem_array_append_one(ARRAY, VAL) \
65 wmem_array_append((ARRAY), &(VAL), 1)
67 WS_DLL_PUBLIC
68 void *
69 wmem_array_index(wmem_array_t *array, unsigned array_index);
71 WS_DLL_PUBLIC
72 int
73 wmem_array_try_index(wmem_array_t *array, unsigned array_index, void *val);
75 WS_DLL_PUBLIC
76 void
77 wmem_array_sort(wmem_array_t *array, int (*compar)(const void*,const void*));
79 WS_DLL_PUBLIC
80 void *
81 wmem_array_get_raw(wmem_array_t *array);
83 WS_DLL_PUBLIC
84 unsigned
85 wmem_array_get_count(wmem_array_t *array);
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.
93 WS_DLL_PUBLIC
94 void *
95 wmem_array_finalize(wmem_array_t *array);
97 WS_DLL_PUBLIC
98 void
99 wmem_destroy_array(wmem_array_t *array);
101 /** @}
102 * @} */
104 #ifdef __cplusplus
106 #endif /* __cplusplus */
108 #endif /* __WMEM_ARRAY_H__ */
111 * Editor modelines - https://www.wireshark.org/tools/modelines.html
113 * Local variables:
114 * c-basic-offset: 4
115 * tab-width: 8
116 * indent-tabs-mode: nil
117 * End:
119 * vi: set shiftwidth=4 tabstop=8 expandtab:
120 * :indentSize=4:tabSize=8:noTabs=true: