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__
18 #include "wmem_core.h"
22 #endif /* __cplusplus */
26 * @defgroup wmem-array Array
28 * A resizable array implementation on top of wmem.
35 typedef struct _wmem_array_t wmem_array_t
;
39 wmem_array_sized_new(wmem_allocator_t
*allocator
, size_t elem_size
,
45 wmem_array_new(wmem_allocator_t
*allocator
, const size_t elem_size
)
50 wmem_array_grow(wmem_array_t
*array
, const unsigned to_add
);
54 wmem_array_set_null_terminator(wmem_array_t
*array
);
58 wmem_array_bzero(wmem_array_t
*array
);
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)
69 wmem_array_index(wmem_array_t
*array
, unsigned array_index
);
73 wmem_array_try_index(wmem_array_t
*array
, unsigned array_index
, void *val
);
77 wmem_array_sort(wmem_array_t
*array
, int (*compar
)(const void*,const void*));
81 wmem_array_get_raw(wmem_array_t
*array
);
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.
95 wmem_array_finalize(wmem_array_t
*array
);
99 wmem_destroy_array(wmem_array_t
*array
);
106 #endif /* __cplusplus */
108 #endif /* __WMEM_ARRAY_H__ */
111 * Editor modelines - https://www.wireshark.org/tools/modelines.html
116 * indent-tabs-mode: nil
119 * vi: set shiftwidth=4 tabstop=8 expandtab:
120 * :indentSize=4:tabSize=8:noTabs=true: