Debian Codegraph @

libcdata/libcdata_array.h

raw symbols SCIP
1 /*
2 * Array functions
3 *
4 * Copyright (C) 2006-2024, Joachim Metz <[email protected]>
5 *
6 * Refer to AUTHORS for acknowledgements.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #if !defined( _LIBCDATA_ARRAY_H )
23 #define _LIBCDATA_ARRAY_H
24
25 #include <common.h>
26 #include <types.h>
27
28 #include "libcdata_extern.h"
29 #include "libcdata_libcerror.h"
30 #include "libcdata_libcthreads.h"
31 #include "libcdata_types.h"
32
33 #if defined( __cplusplus )
34 extern "C" {
35 #endif
36
37 typedef struct libcdata_internal_array libcdata_internal_array_t;
38
39 struct libcdata_internal_array
40 {
41 /* The number of allocated entries
42 */
43 int number_of_allocated_entries;
44
45 /* The number of entries
46 */
47 int number_of_entries;
48
49 /* The entries
50 */
51 intptr_t **entries;
52
53 #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA )
54 /* The read/write lock
55 */
56 libcthreads_read_write_lock_t *read_write_lock;
57 #endif
58 };
59
60 LIBCDATA_EXTERN \
61 int libcdata_array_initialize(
62 libcdata_array_t **array,
63 int number_of_entries,
64 libcerror_error_t **error );
65
66 LIBCDATA_EXTERN \
67 int libcdata_array_free(
68 libcdata_array_t **array,
69 int (*entry_free_function)(
70 intptr_t **entry,
71 libcerror_error_t **error ),
72 libcerror_error_t **error );
73
74 LIBCDATA_EXTERN \
75 int libcdata_array_empty(
76 libcdata_array_t *array,
77 int (*entry_free_function)(
78 intptr_t **entry,
79 libcerror_error_t **error ),
80 libcerror_error_t **error );
81
82 int libcdata_internal_array_clear(
83 libcdata_internal_array_t *internal_array,
84 int (*entry_free_function)(
85 intptr_t **entry,
86 libcerror_error_t **error ),
87 libcerror_error_t **error );
88
89 LIBCDATA_EXTERN \
90 int libcdata_array_clear(
91 libcdata_array_t *array,
92 int (*entry_free_function)(
93 intptr_t **entry,
94 libcerror_error_t **error ),
95 libcerror_error_t **error );
96
97 LIBCDATA_EXTERN \
98 int libcdata_array_clone(
99 libcdata_array_t **destination_array,
100 libcdata_array_t *source_array,
101 int (*entry_free_function)(
102 intptr_t **entry,
103 libcerror_error_t **error ),
104 int (*entry_clone_function)(
105 intptr_t **destination_entry,
106 intptr_t *source_entry,
107 libcerror_error_t **error ),
108 libcerror_error_t **error );
109
110 int libcdata_internal_array_resize(
111 libcdata_internal_array_t *internal_array,
112 int number_of_entries,
113 int (*entry_free_function)(
114 intptr_t **entry,
115 libcerror_error_t **error ),
116 libcerror_error_t **error );
117
118 LIBCDATA_EXTERN \
119 int libcdata_array_resize(
120 libcdata_array_t *array,
121 int number_of_entries,
122 int (*entry_free_function)(
123 intptr_t **entry,
124 libcerror_error_t **error ),
125 libcerror_error_t **error );
126
127 LIBCDATA_EXTERN \
128 int libcdata_array_reverse(
129 libcdata_array_t *array,
130 libcerror_error_t **error );
131
132 LIBCDATA_EXTERN \
133 int libcdata_array_get_number_of_entries(
134 libcdata_array_t *array,
135 int *number_of_entries,
136 libcerror_error_t **error );
137
138 LIBCDATA_EXTERN \
139 int libcdata_array_get_entry_by_index(
140 libcdata_array_t *array,
141 int entry_index,
142 intptr_t **entry,
143 libcerror_error_t **error );
144
145 LIBCDATA_EXTERN \
146 int libcdata_array_get_entry_by_value(
147 libcdata_array_t *array,
148 intptr_t *entry,
149 int (*entry_compare_function)(
150 intptr_t *first_entry,
151 intptr_t *second_entry,
152 libcerror_error_t **error ),
153 intptr_t **existing_entry,
154 libcerror_error_t **error );
155
156 LIBCDATA_EXTERN \
157 int libcdata_array_set_entry_by_index(
158 libcdata_array_t *array,
159 int entry_index,
160 intptr_t *entry,
161 libcerror_error_t **error );
162
163 LIBCDATA_EXTERN \
164 int libcdata_array_prepend_entry(
165 libcdata_array_t *array,
166 intptr_t *entry,
167 libcerror_error_t **error );
168
169 LIBCDATA_EXTERN \
170 int libcdata_array_append_entry(
171 libcdata_array_t *array,
172 int *entry_index,
173 intptr_t *entry,
174 libcerror_error_t **error );
175
176 LIBCDATA_EXTERN \
177 int libcdata_array_insert_entry(
178 libcdata_array_t *array,
179 int *entry_index,
180 intptr_t *entry,
181 int (*entry_compare_function)(
182 intptr_t *first_entry,
183 intptr_t *second_entry,
184 libcerror_error_t **error ),
185 uint8_t insert_flags,
186 libcerror_error_t **error );
187
188 LIBCDATA_EXTERN \
189 int libcdata_array_remove_entry(
190 libcdata_array_t *array,
191 int entry_index,
192 intptr_t **entry,
193 libcerror_error_t **error );
194
195 #if defined( __cplusplus )
196 }
197 #endif
198
199 #endif /* !defined( _LIBCDATA_ARRAY_H ) */
200