blob: b88482fe4f9097954d5eada3fff14407f33aba93 [file] [log] [blame]
Lucas De Marchie8fd8fe2012-07-18 10:19:48 -03001#pragma once
Lucas De Marchi6670c632011-12-28 12:53:37 -02002
Lucas De Marchi74d1df62014-10-03 00:22:36 -03003#include <stddef.h>
4
Lucas De Marchi6670c632011-12-28 12:53:37 -02005/*
6 * Declaration of struct array is in header because we may want to embed the
7 * structure into another, so we need to know its size
8 */
9struct array {
10 void **array;
11 size_t count;
12 size_t total;
13 size_t step;
14};
15
16void array_init(struct array *array, size_t step);
17int array_append(struct array *array, const void *element);
18int array_append_unique(struct array *array, const void *element);
19void array_pop(struct array *array);
20void array_free_array(struct array *array);
21void array_sort(struct array *array, int (*cmp)(const void *a, const void *b));
Gustavo Sverzut Barbieri79b656f2012-01-03 15:58:24 -020022int array_remove_at(struct array *array, unsigned int pos);