by mklencke · 15y ago · 0 comments
typedef struct { void *elements; int elem_size; int n; } Vector;
Vector *vector_new(int elem_size);
void vector_free(Vector *v);
void vector_push(Vector *v, void *elem);
void vector_pop(Vector *v);
int vector_size(Vector *v);
void *vector_at(Vector *v, int i);
etc. This is off the top of my head, but you get the idea. You can basically put anything you want in there as long as you say how large the elements are upon initialization.There is a good book on generic C programming: http://sites.google.com/site/cinterfacesimplementations/
*(int *)vector_expand(v) = 2;