~donmcc/ood

ref: b1579e4c3e21c6863b468633747acfc21ed51a9a ood/src/libood/ood/ptr_array.h -rw-r--r-- 893 bytes
b1579e4cDon McCaughey Rename `ood_ptr_array_add_realloc()`. 2 months ago
                                                                                
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
40
41
42
43
44
45
46
47
#ifndef OOD_PTR_ARRAY_H_INCLUDED
#define OOD_PTR_ARRAY_H_INCLUDED


#include <stdbool.h>
#include "ood/result.h"


struct ood_ptr_array {
    void **items;
    int count;
    int capacity;
};


struct ood_ptr_array *
ood_ptr_array_alloc(int capacity);

void
ood_ptr_array_free(struct ood_ptr_array *array);

bool
ood_ptr_array_has_capacity(struct ood_ptr_array *array);

enum ood_result
ood_ptr_array_add(struct ood_ptr_array *array, void *item);

enum ood_result
ood_ptr_array_realloc_add(struct ood_ptr_array *array, void *item);

enum ood_result
ood_ptr_array_clear(struct ood_ptr_array *array, void *item);

void *
ood_ptr_array_next(struct ood_ptr_array const *array, int *i);

void *
ood_ptr_array_previous(struct ood_ptr_array const *array, int *i);

void *
ood_ptr_array_first(struct ood_ptr_array const *array);

void *
ood_ptr_array_last(struct ood_ptr_array const *array);


#endif