"Reinventing the bicycle"-class C vector library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Kasianov Nikolai Alekseevich 13705cd698 make test and c color formatting in README 2 years ago
src Set vector contents to NULL upon freeing 2 years ago
testing Initial commit 2 years ago
.gitignore Initial commit 2 years ago
LICENSE Initial commit 2 years ago
Makefile make test and c color formatting in README 2 years ago
README.md make test and c color formatting in README 2 years ago

README.md

CVEC - C vector

"Reinventing the bicycle"-class C vector library

Usage

The values are stored internally in vector's contents as chars so any types fit, but only one type per vector should be used. It is your responsibility to not use different types in one vector.

The overall usage should be done via shipped cvec_* functions, but in case of the need for some pointer math magic, all necessary fields are there for your usage.

This snippet should give you the general idea of usage.

cvec vec = cvec_new(sizeof(size_t), 1);
size_t val = 0x15dc;
cvec_put(&vec, &val);
printf("sizeof(size_t) -> %zu\n", sizeof(size_t));
printf("%s; size %zu\n", vec.contents, vec.size);
val = 0x02ec;
cvec_put(&vec, &val);
printf("After realloc: %s; size: %zu\n", vec.contents, vec.size);
printf("At index %d: %zx\n", 1, *(size_t*) cvec_at(&vec, 1));
cvec_free(&vec);

License

MIT