behold: a generic data structure operation in C
#define VECTOR_PUSH(v,item,type) \
type *array = (type *)((v)->array); \
array[(v)->size] = (item); \
++((v)->size); \
if((v)->size == (v)->capacity){ \
(v)->capacity *= 2; \
array = realloc(array,sizeof(type)*(v)->capacity); \
}