#include <stddef.h>
#include <string.h>
#include <stdlib.h>
Go to the source code of this file.
|
#define | UTARRAY_VERSION 1.9.9 |
|
#define | _UNUSED_ |
|
#define | oom() exit(-1) |
|
#define | utarray_init(a, _icd) |
|
#define | utarray_done(a) |
|
#define | utarray_new(a, _icd) |
|
#define | utarray_free(a) |
|
#define | utarray_reserve(a, by) |
|
#define | utarray_push_back(a, p) |
|
#define | utarray_pop_back(a) |
|
#define | utarray_extend_back(a) |
|
#define | utarray_len(a) ((a)->i) |
|
#define | utarray_eltptr(a, j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL) |
|
#define | _utarray_eltptr(a, j) ((char*)((a)->d + ((a)->icd.sz*(j) ))) |
|
#define | utarray_insert(a, p, j) |
|
#define | utarray_inserta(a, w, j) |
|
#define | utarray_resize(dst, num) |
|
#define | utarray_concat(dst, src) |
|
#define | utarray_erase(a, pos, len) |
|
#define | utarray_renew(a, u) |
|
#define | utarray_clear(a) |
|
#define | utarray_sort(a, cmp) |
|
#define | utarray_find(a, v, cmp) bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp) |
|
#define | utarray_front(a) (((a)->i) ? (_utarray_eltptr(a,0)) : NULL) |
|
#define | utarray_next(a, e) (((e)==NULL) ? utarray_front(a) : ((((a)->i) > (utarray_eltidx(a,e)+1)) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL)) |
|
#define | utarray_prev(a, e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) > 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL)) |
|
#define | utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL) |
|
#define | utarray_eltidx(a, e) (((char*)(e) >= (char*)((a)->d)) ? (((char*)(e) - (char*)((a)->d))/(size_t)(a)->icd.sz) : -1) |
|
|
typedef void( | ctor_f) (void *dst, const void *src) |
|
typedef void( | dtor_f) (void *elt) |
|
typedef void( | init_f) (void *elt) |
|
#define _utarray_eltptr |
( |
|
a, |
|
|
|
j |
|
) |
| ((char*)((a)->d + ((a)->icd.sz*(j) ))) |
#define utarray_clear |
( |
|
a | ) |
|
Value:do { \
if ((a)->i > 0) { \
if ((a)->icd.dtor) { \
size_t _ut_i; \
for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \
} \
} \
(a)->i = 0; \
} \
} while(0)
#define utarray_eltptr(a, j)
Definition at line 194 of file utarray.h.
#define utarray_concat |
( |
|
dst, |
|
|
|
src |
|
) |
| |
Value:
} while(0)
#define utarray_inserta(a, w, j)
Definition at line 171 of file utarray.h.
#define utarray_done |
( |
|
a | ) |
|
Value:do { \
if ((a)->n) { \
if ((a)->icd.dtor) { \
size_t _ut_i; \
for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \
} \
} \
free((a)->d); \
} \
(a)->n=0; \
} while(0)
#define utarray_eltptr(a, j)
Definition at line 64 of file utarray.h.
#define utarray_eltidx |
( |
|
a, |
|
|
|
e |
|
) |
| (((char*)(e) >= (char*)((a)->d)) ? (((char*)(e) - (char*)((a)->d))/(size_t)(a)->icd.sz) : -1) |
#define utarray_erase |
( |
|
a, |
|
|
|
pos, |
|
|
|
len |
|
) |
| |
Value:do { \
if ((a)->icd.dtor) { \
size_t _ut_i; \
for(_ut_i=0; _ut_i < len; _ut_i++) { \
} \
} \
if ((a)->i > (pos+len)) { \
(((a)->i)-(pos+len))*((a)->icd.sz)); \
} \
(a)->i -= (len); \
} while(0)
#define utarray_eltptr(a, j)
#define _utarray_eltptr(a, j)
Definition at line 175 of file utarray.h.
#define utarray_extend_back |
( |
|
a | ) |
|
Value:
(a)->i++; \
} while(0)
#define utarray_reserve(a, by)
void * memset(void *b, int c, int len)
#define _utarray_eltptr(a, j)
Definition at line 105 of file utarray.h.
#define utarray_find |
( |
|
a, |
|
|
|
v, |
|
|
|
cmp |
|
) |
| bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp) |
#define utarray_free |
( |
|
a | ) |
|
#define utarray_init |
( |
|
a, |
|
|
|
_icd |
|
) |
| |
Value:
(a)->icd=*_icd; \
} while(0)
void * memset(void *b, int c, int len)
Definition at line 59 of file utarray.h.
#define utarray_insert |
( |
|
a, |
|
|
|
p, |
|
|
|
j |
|
) |
| |
Value:do { \
if ((j) < (a)->i) { \
((a)->i - (j))*((a)->icd.sz)); \
} \
(a)->i++; \
} while(0)
#define utarray_resize(dst, num)
#define utarray_reserve(a, by)
#define _utarray_eltptr(a, j)
void * memcpy(void *str1, const void *str2, long n)
Definition at line 117 of file utarray.h.
#define utarray_inserta |
( |
|
a, |
|
|
|
w, |
|
|
|
j |
|
) |
| |
Value:do { \
if ((j) < (a)->i) { \
((a)->i - (j))*((a)->icd.sz)); \
} \
if ((a)->icd.copy) { \
size_t _ut_i; \
for(_ut_i=0;_ut_i<(w)->i;_ut_i++) { \
} \
} \
} while(0)
#define utarray_resize(dst, num)
#define utarray_reserve(a, by)
#define _utarray_eltptr(a, j)
void * memcpy(void *str1, const void *str2, long n)
Definition at line 129 of file utarray.h.
#define utarray_len |
( |
|
a | ) |
((a)->i) |
#define utarray_new |
( |
|
a, |
|
|
|
_icd |
|
) |
| |
Value:do { \
} while(0)
#define utarray_init(a, _icd)
Definition at line 77 of file utarray.h.
#define utarray_pop_back |
( |
|
a | ) |
|
Value:do { \
else { (a)->i--; } \
} while(0)
#define _utarray_eltptr(a, j)
Definition at line 100 of file utarray.h.
#define utarray_push_back |
( |
|
a, |
|
|
|
p |
|
) |
| |
Value:
} while(0)
#define utarray_reserve(a, by)
#define _utarray_eltptr(a, j)
void * memcpy(void *str1, const void *str2, long n)
Definition at line 94 of file utarray.h.
#define utarray_renew |
( |
|
a, |
|
|
|
u |
|
) |
| |
Value:do { \
} while(0)
#define utarray_new(a, _icd)
Definition at line 189 of file utarray.h.
#define utarray_reserve |
( |
|
a, |
|
|
|
by |
|
) |
| |
Value:do { \
if (((a)->i+by) > ((a)->n)) { \
while(((a)->i+by) > ((a)->n)) { (a)->n = ((a)->n ? (2*(a)->n) : 8); } \
if ( ((a)->d=(
char*)realloc((a)->d, (a)->n*(a)->icd.sz)) ==
NULL)
oom(); \
} \
} while(0)
Definition at line 87 of file utarray.h.
#define utarray_resize |
( |
|
dst, |
|
|
|
num |
|
) |
| |
Value:do { \
size_t _ut_i; \
if (dst->i > (size_t)(num)) { \
if ((dst)->icd.dtor) { \
for(_ut_i=num; _ut_i < dst->i; _ut_i++) { \
} \
} \
}
else if (dst->i < (
size_t)(num)) {
\
if ((dst)->icd.init) { \
for(_ut_i=dst->i; _ut_i < num; _ut_i++) { \
} \
} \
} \
dst->i = num; \
} while(0)
#define utarray_reserve(a, by)
void * memset(void *b, int c, int len)
#define utarray_eltptr(a, j)
#define _utarray_eltptr(a, j)
Definition at line 150 of file utarray.h.
#define utarray_sort |
( |
|
a, |
|
|
|
cmp |
|
) |
| |
Value:do { \
qsort((a)->d, (a)->i, (a)->icd.sz, cmp); \
} while(0)
Definition at line 206 of file utarray.h.
#define UTARRAY_VERSION 1.9.9 |
typedef void( ctor_f) (void *dst, const void *src) |
typedef void( dtor_f) (void *elt) |
typedef void( init_f) (void *elt) |
static void utarray_str_cpy |
( |
void * |
dst, |
|
|
const void * |
src |
|
) |
| |
|
static |
Definition at line 219 of file utarray.h.
References NULL, and strdup().
220 char **_src = (
char**)src, **_dst = (
char**)dst;
char * strdup(const char *str)
static void utarray_str_dtor |
( |
void * |
elt | ) |
|
|
static |
Definition at line 223 of file utarray.h.
224 char **eltc = (
char**)elt;
225 if (*eltc) free(*eltc);