Library with useful C data structures
A vector is type agnostic structure similar to a list that grows as needed.
Install check, unit tests framework. Now you can run the lib tests:
$ cd vector
$ make
This example creates a vector of strings with initial 10 positions allocated:
#include <stdio.h>
#include <string.h>
#include "vector.h"
void free_string(void *string) {
free(*(char **)string);
}
int main(void) {
vector *v = vector_new(sizeof(char *), free_string, 10);
char *name = strdup("Igor");
vector_append(v, &name);
printf("%s \n", *(char **)vector_get(v, 0));
vector_free(v);
return EXIT_SUCCESS;
}