Closed dm9pZCAq closed 1 year ago
There already is a destructor macro, called cvector_elem_destructor
. And if you look at the cvector_free
macro, it actually will call it on each element before freeing the vector itself.
So I'm not sure that what your proposing would add anything not already there, please re-open if I'm mistaken.
I propose adding a vector destructor that would be called by
cvector_free
.For example, consider the scenario where I read a file and store pointers to the beginning of each line in the vector (with newline characters
\n
replaced with null bytes\0
).The file data would look something like this:
With the addition of a vector destructor, I would be able to free all the data by using the first pointer (
vec[0]
). This would provide a cleaner and more efficient way to manage memory when usingcvector
.