1*cc4ad7daSAndroid Build Coastguard Worker #pragma once 2*cc4ad7daSAndroid Build Coastguard Worker 3*cc4ad7daSAndroid Build Coastguard Worker #include <stddef.h> 4*cc4ad7daSAndroid Build Coastguard Worker 5*cc4ad7daSAndroid Build Coastguard Worker /* 6*cc4ad7daSAndroid Build Coastguard Worker * Declaration of struct array is in header because we may want to embed the 7*cc4ad7daSAndroid Build Coastguard Worker * structure into another, so we need to know its size 8*cc4ad7daSAndroid Build Coastguard Worker */ 9*cc4ad7daSAndroid Build Coastguard Worker struct array { 10*cc4ad7daSAndroid Build Coastguard Worker void **array; 11*cc4ad7daSAndroid Build Coastguard Worker size_t count; 12*cc4ad7daSAndroid Build Coastguard Worker size_t total; 13*cc4ad7daSAndroid Build Coastguard Worker size_t step; 14*cc4ad7daSAndroid Build Coastguard Worker }; 15*cc4ad7daSAndroid Build Coastguard Worker 16*cc4ad7daSAndroid Build Coastguard Worker void array_init(struct array *array, size_t step); 17*cc4ad7daSAndroid Build Coastguard Worker int array_append(struct array *array, const void *element); 18*cc4ad7daSAndroid Build Coastguard Worker int array_append_unique(struct array *array, const void *element); 19*cc4ad7daSAndroid Build Coastguard Worker void array_pop(struct array *array); 20*cc4ad7daSAndroid Build Coastguard Worker void array_free_array(struct array *array); 21*cc4ad7daSAndroid Build Coastguard Worker void array_sort(struct array *array, int (*cmp)(const void *a, const void *b)); 22*cc4ad7daSAndroid Build Coastguard Worker int array_remove_at(struct array *array, unsigned int pos); 23