diff options
-rw-r--r-- | lib/cbit/vec.h | 5 | ||||
-rw-r--r-- | test/test-vec.cpp | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/cbit/vec.h b/lib/cbit/vec.h index cbefc0c..c291b41 100644 --- a/lib/cbit/vec.h +++ b/lib/cbit/vec.h @@ -120,6 +120,11 @@ void vec_realloc_internal_as_necessary(struct vec_internal *vi, v->els = v->storage; \ } while (0) +#define VEC_STORAGE_INIT_STATIC(vs, name) \ + {{0, \ + (sizeof((vs)->rest) / sizeof((vs)->rest[0])) + 1, \ + (vs)->v.storage \ + }} /* guaranteed to *not* cache vec->length - pretty simple */ diff --git a/test/test-vec.cpp b/test/test-vec.cpp index 9bb3daa..b26ec53 100644 --- a/test/test-vec.cpp +++ b/test/test-vec.cpp @@ -4,7 +4,7 @@ DECL_VEC(const char *, ccp); DECL_VEC(int, int); int main() { - VEC_STORAGE(ccp) stor; + VEC_STORAGE(ccp) stor = VEC_STORAGE_INIT_STATIC(&stor, cpp); VEC_STORAGE_INIT(&stor, ccp); struct vec_ccp *vec = &stor.v; for (int i = 0; i < 20; i++) { |