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
2f7f1a8a40
|
2 years ago | |
---|---|---|
src | 2 years ago | |
testing | 2 years ago | |
.gitignore | 2 years ago | |
LICENSE | 2 years ago | |
Makefile | 2 years ago | |
README.md | 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 char
s 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