darray: hkl Reference Manual

## darray darray |

## Functions

#define | darray()
#define | darray_new
#define | darray_init()
#define | darray_free()
#define | darray_item()
#define | darray_size()
#define | darray_alloc()
#define | darray_empty()
#define | darray_append()
#define | darray_prepend()
#define | darray_insert()
#define | darray_push()
#define | darray_append_items()
#define | darray_prepend_items()
#define | darray_append_items_nullterminate()
#define | darray_prepend_items_nullterminate()
#define | darray_appends()
#define | darray_prepends()
#define | darray_appends_t()
#define | darray_prepends_t()
#define | darray_pop()
#define | darray_pop_check()
#define | darray_remove()
#define | darray_from_items()
#define | darray_from_c()
#define | darray_append_string()
#define | darray_append_lit()
#define | darray_prepend_string()
#define | darray_prepend_lit()
#define | darray_from_string()
#define | darray_from_lit()
#define | darray_resize()
#define | darray_resize0()
#define | darray_realloc()
#define | darray_growalloc()
#define | darray_make_room()
size_t | darray_next_alloc ()
#define | darray_foreach()
#define | darray_foreach_reverse()

## Types and Values

typedef | darray_char
typedef | darray_schar
typedef | darray_uchar
typedef | darray_short
typedef | darray_int
typedef | darray_long
typedef | darray_ushort
typedef | darray_uint
typedef | darray_ulong

## Description

## Functions

### darray()

    #define darray(type) struct {type *item; size_t size; size_t alloc;}

### darray_new

    #define darray_new() {0,0,0}

### darray_init()

    #define darray_init(arr) do {(arr).item=0; (arr).size=0; (arr).alloc=0;} while(0)

### darray_free()

    #define darray_free(arr) do {free((arr).item);} while(0)

### darray_item()

    #define darray_item(arr, i) ((arr).item[i])

### darray_size()

    #define darray_size(arr)    ((arr).size)

### darray_alloc()

    #define darray_alloc(arr)   ((arr).alloc)

### darray_empty()

    #define darray_empty(arr)   ((arr).size == 0)

### darray_append()

    #define             darray_append(arr, ...)

### darray_prepend()

    #define             darray_prepend(arr, ...)

### darray_insert()

    #define             darray_insert(arr, i, ...)

### darray_push()

    #define darray_push(arr, ...) darray_append(arr, __VA_ARGS__)

### darray_append_items()

    #define             darray_append_items(arr, items, count)

### darray_prepend_items()

    #define             darray_prepend_items(arr, items, count)

### darray_append_items_nullterminate()

    #define             darray_append_items_nullterminate(arr, items, count)

### darray_prepend_items_nullterminate()

    #define             darray_prepend_items_nullterminate(arr, items, count)

### darray_appends()

    #define darray_appends(arr, ...) darray_appends_t(arr, typeof((*(arr).item)), __VA_ARGS__)

### darray_prepends()

    #define darray_prepends(arr, ...) darray_prepends_t(arr, typeof((*(arr).item)), __VA_ARGS__)

### darray_appends_t()

    #define             darray_appends_t(arr, type, ...)

### darray_prepends_t()

    #define             darray_prepends_t(arr, type, ...)

### darray_pop()

    #define darray_pop(arr) ((arr).item[--(arr).size])

### darray_pop_check()

    #define darray_pop_check(arr) ((arr).size ? darray_pop(arr) : NULL)

### darray_remove()

    #define             darray_remove(arr, i)

### darray_from_items()

    #define darray_from_items(arr, items, count) do {size_t count_ = (count); darray_resize(arr, count_); memcpy((arr).item, items, count_*sizeof(*(arr).item));} while(0)

### darray_from_c()

    #define darray_from_c(arr, c_array) darray_from_items(arr, c_array, sizeof(c_array)/sizeof(*(c_array)))

### darray_append_string()

    #define darray_append_string(arr, str) do {const char *str_ = (str); darray_append_items(arr, str_, strlen(str_)+1); (arr).size--;} while(0)

### darray_append_lit()

    #define darray_append_lit(arr, stringLiteral) do {darray_append_items(arr, stringLiteral, sizeof(stringLiteral)); (arr).size--;} while(0)

### darray_prepend_string()

    #define             darray_prepend_string(arr, str)

### darray_prepend_lit()

    #define             darray_prepend_lit(arr, stringLiteral)

### darray_from_string()

    #define darray_from_string(arr, str) do {const char *str_ = (str); darray_from_items(arr, str_, strlen(str_)+1); (arr).size--;} while(0)

### darray_from_lit()

    #define darray_from_lit(arr, stringLiteral) do {darray_from_items(arr, stringLiteral, sizeof(stringLiteral)); (arr).size--;} while(0)

### darray_resize()

    #define darray_resize(arr, newSize) darray_growalloc(arr, (arr).size = (newSize))

### darray_resize0()

    #define             darray_resize0(arr, newSize)

### darray_realloc()

    #define             darray_realloc(arr, newAlloc)

### darray_growalloc()

    #define             darray_growalloc(arr, need)

### darray_make_room()

    #define darray_make_room(arr, room) ({size_t newAlloc = (arr).size+(room); if ((arr).alloc<newAlloc) darray_realloc(arr, newAlloc); (arr).item+(arr).size; })

### darray_next_alloc ()

    size_t
    darray_next_alloc (size_t alloc,
                       size_t need);

### darray_foreach()

    #define             darray_foreach(i, arr)

### darray_foreach_reverse()

    #define             darray_foreach_reverse(i, arr)

## Types and Values

### darray_char

    typedef darray(char)           darray_char;

### darray_schar

    typedef darray(signed char)    darray_schar;

### darray_uchar

    typedef darray(unsigned char)  darray_uchar;

### darray_short

    typedef darray(short)          darray_short;

### darray_int

    typedef darray(int)            darray_int;

### darray_long

    typedef darray(long)           darray_long;

### darray_ushort

    typedef darray(unsigned short) darray_ushort;

### darray_uint

    typedef darray(unsigned int)   darray_uint;

### darray_ulong

    typedef darray(unsigned long)  darray_ulong;