[vlc-devel] [RFC 0/1] vlc_vector

Romain Vimont rom1v at videolabs.io
Wed Aug 29 22:28:19 CEST 2018


Last month, I proposed some improvements to vlc_array_t:
<https://mailman.videolan.org/pipermail/vlc-devel/2018-July/120434.html>

But vlc_array_t has major drawbacks:
 - it only supports pointers;
 - it is not type-safe (it only handles void*).

The best candidate to improve was then ARRAY_* (which already uses an
exponential growth policy), but:
 - it aborts on allocation failure;
 - it does not check for overflows (on grow and reallocation).

Improving ARRAY_* would be quite difficult, because it would require to
analyze every usage, typically to replace int by size_t (useful to check
for overflow properly).

Therefore, I decided to implement (yet) another tool, which is intended
to replace ARRAY_*: vlc_vector.

The macros involving possible allocation are written so that they can
yield a bool to report errors, without requiring an additional parameter.

This is just an RFC for now because I just wrote unit tests for it, I
didn't used it in real code yet.

Romain Vimont (1):
  vlc_vector: add helpers for vectors

 include/vlc_common.h |   6 +
 include/vlc_vector.h | 397 +++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am      |   5 +-
 src/test/vector.c    | 362 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 769 insertions(+), 1 deletion(-)
 create mode 100644 include/vlc_vector.h
 create mode 100644 src/test/vector.c

-- 
2.18.0



More information about the vlc-devel mailing list