c-vector icon indicating copy to clipboard operation
c-vector copied to clipboard

A dynamic array implementation in C similar to the one found in standard C++

Results 9 c-vector issues
Sort by recently updated
recently updated
newest added

Strictly speaking, the C standard does not guarantee unaligned memory accesses to work. So any time sizeof (*vec) is bigger than sizeof (size_t), accessing *vec is undefined. sizeof (size_t) is...

PR is still in early state. It's not fully tested and still buggy. Here is how I would try to tackle the issue https://github.com/eteran/c-vector/issues/40. I introduced several helper macros that...

What do you think about automatic shrinking of c-vectors? Currently, the vector capacity doubles when `capacity == size`. How about cutting the vector capacity in half when the `(size >>...

Adding some basic functions : cvector_at, cvector_back and cvector_front

1. Make grow strategy local per vector instead of using it globally 2. Add cast in cvector_reserve allowing to use signed integers as a parameter of the macro

I think macro named `cvector_free_each_and_free` defined in `cvector_utils.h` should be named `cvector_for_each_and_free`

https://cplusplus.com/reference/vector/vector/at/ This adds a `cvector_at()` function which aims to be implement [`std::vector::at()`](https://en.cppreference.com/w/cpp/container/vector/at). I'm not sure if the typecasting is correct, or even the approach. Would love some input.

Fixed the issue of cvector_resize not resizing the vector if it is equal to NULL (a newly created vector).

Great work! I had a different vector construction setup, then came across your feature for regular array index access. I scraped/refactored my version in https://github.com/zelang-dev/c-raii/tree/main/src/vector.c to use yours exclusively, memory...