The vec library

#include "/package/prog/prjlibs/include/vec.h"

typedef VEC_T(int) intvec_t;

void        VEC_INIT(int, intvec_t* pvec);
void        VEC_FREE(int, intvec_t* pvec);

size_t      VEC_LEN(int, intvec_t* pvec);
size_t      VEC_BLEN(int, intvec_t* pvec);
int*        VEC_ELTS(int, intvec_t const* pvec);
int*        VEC_ELT(int, intvec_t const* pvec, size_t i);

type_status VEC_ALLOC(int, intvec_t* pvec, size_t newlength,
                      type_bool additional);
type_status VEC_ALLOCFIT(int, intvec_t* pvec);
type_status VEC_TRUNC(int, intvec_t* pvec, size_t newlength);

size_t      VEC_DIFFI(int, intvec_t const* pvec0, intvec_t const* pvec1);
type_bool   VEC_EQ(int, intvec_t const* pvec0, intvec_t const* pvec1);

type_status VEC_INSN(int, intvec_t* pvec, size_t position,
                     int const* newitems, size_t nitems);
type_status VEC_INSA(int, intvec_t* pvec, size_t position,
                     int const* newitems, type_bool trim);
type_status VEC_INS1(int, intvec_t* pvec, size_t position, int newitem);
type_status VEC_PUSHN(int, intvec_t* pvec, int const* newitems, size_t nitems);
type_status VEC_PUSHA(int, intvec_t* pvec,
                      int const* newitems, type_bool trim);
type_status VEC_PUSH1(int, intvec_t* pvec, int newitem);
type_status VEC_UNSHIFTN(int, intvec_t* pvec,
                         int const* newitems, size_t nitems);
type_status VEC_UNSHIFTA(int, intvec_t* pvec,
                         int const* newitems, type_bool trim);
type_status VEC_UNSHIFT1(int, intvec_t* pvec, int newitem);

type_status VEC_CUTN(int, intvec_t* pvec, size_t position,
                     int* olditems, size_t nitems);
type_status VEC_CUT1(int, intvec_t* pvec, size_t position, int* olditem);
int*        VEC_POPN(int, intvec_t* pvec, size_t nitems);
int*        VEC_POP1(int, intvec_t* pvec);
type_status VEC_SHIFTN(int, intvec_t* pvec, int* olditems, size_t nitems);
int*        VEC_SHIFT1(int, intvec_t* pvec);

type_status VEC_INSS(VEC_T(char)* cvec, size_t position,
                     char const* newitems, type_bool trim);
type_status VEC_PUSHS(VEC_T(char)* cvec,
                      char const* newitems, type_bool trim);
type_status VEC_UNSHIFTS(VEC_T(char)* cvec,
                         char const* newitems, type_bool trim);

The vec library provides type-generic, type-safe, dynamically allocated vectors.

To link your program with the vec library, add /package/prog/prjlibs/library/vec.a to the end of the link command line.

Performance tips: