summaryrefslogtreecommitdiff
path: root/array.h
blob: 340cda0a06321c54936995fee02464f0b77ea249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdint.h>
#include <stdlib.h>

typedef int bool_t;
typedef struct array_t array_t;

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

bool_t
array_create (array_t **array, size_t element_size);

void
array_free (array_t **array);

void
array_delete_tail (array_t **array, size_t n_delete);

void *
array_get_data (array_t **array, size_t *n_elements);

/* append @n_elements elements with undefined content and
 * return a pointer to the first appended element tail.
 *
 * E.g. for an array of integers, do this:
 *
 *     int *tail;
 *     if (array_append (array, 17, &tail))
 *     {
 *        <fill out the 17 elements pointed to by tail>
 *     }
 */
bool_t
array_append (array_t **array, size_t n_elements, void *tail);