Internal array changed to array of bytes.
[myarray.git] / myarray.h
blob8e8d24831d5046a4cfcd33d0db1f4735b4083df2
1 #ifndef _MYARRAY_H
2 #define _MYARRAY_H
3 #include <stdint.h>
4 #include <string.h>
6 typedef struct myarray {
7 uint8_t *elements;
8 int len;
9 int maxlen;
10 int incr;
11 int elsize;
12 int (*cmpfunc)(void *, void *);
13 } *MArray;
15 MArray myarray_new(int, int, int);
17 #define myarray_append(a,e) _myarray_insert((a), &(e), (a)->len)
19 #define myarray_insert(a,e,i) _myarray_insert((a), &(e), (i))
20 void _myarray_insert(MArray, void *, int);
22 #define myarray_get(a,t,i) (((t*) ((a)->elements))[(i)])
24 void myarray_remove_index(MArray, int);
26 void myarray_reset(MArray);
28 void myarray_free(MArray);
30 void myarray_set_cmpfunc(MArray array, int (*cmpfunc)(void *, void *));
32 #define myarray_insert_sorted(a,e) _myarray_insert_sorted(a, &(e))
33 void _myarray_insert_sorted(MArray array, void *element);
34 #endif