File indexing completed on 2025-12-16 10:19:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef _json_c_arraylist_h_
0019 #define _json_c_arraylist_h_
0020
0021 #ifdef __cplusplus
0022 extern "C" {
0023 #endif
0024
0025 #include <stddef.h>
0026
0027 #define ARRAY_LIST_DEFAULT_SIZE 32
0028
0029 typedef void(array_list_free_fn)(void *data);
0030
0031 struct array_list
0032 {
0033 void **array;
0034 size_t length;
0035 size_t size;
0036 array_list_free_fn *free_fn;
0037 };
0038 typedef struct array_list array_list;
0039
0040
0041
0042
0043
0044 extern struct array_list *array_list_new(array_list_free_fn *free_fn);
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 extern struct array_list *array_list_new2(array_list_free_fn *free_fn, int initial_size);
0060
0061 extern void array_list_free(struct array_list *al);
0062
0063 extern void *array_list_get_idx(struct array_list *al, size_t i);
0064
0065 extern int array_list_insert_idx(struct array_list *al, size_t i, void *data);
0066
0067 extern int array_list_put_idx(struct array_list *al, size_t i, void *data);
0068
0069 extern int array_list_add(struct array_list *al, void *data);
0070
0071 extern size_t array_list_length(struct array_list *al);
0072
0073 extern void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *));
0074
0075 extern void *array_list_bsearch(const void **key, struct array_list *arr,
0076 int (*compar)(const void *, const void *));
0077
0078 extern int array_list_del_idx(struct array_list *arr, size_t idx, size_t count);
0079
0080
0081
0082
0083
0084 extern int array_list_shrink(struct array_list *arr, size_t empty_slots);
0085
0086 #ifdef __cplusplus
0087 }
0088 #endif
0089
0090 #endif