From 8866762e0f90a9320ef27e883e719fc69007aee5 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 2 May 2024 15:07:58 -0400 Subject: [PATCH] cvector_resize: Fix clang-format --- cvector.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/cvector.h b/cvector.h index b8e8a30..af869be 100644 --- a/cvector.h +++ b/cvector.h @@ -457,24 +457,23 @@ typedef struct cvector_metadata_t { * @param value - the value to initialize new elements with * @return void */ -#define cvector_resize(vec, count, value) \ - do { \ - if (vec) { \ - size_t cv_sz_count__ = (size_t)(count); \ - size_t cv_sz__ = cvector_size(vec); \ - if (cv_sz_count__ > cv_sz__) { \ - cvector_reserve((vec), cv_sz_count__); \ - cvector_set_size((vec), cv_sz_count__); \ - do { \ - (vec)[cv_sz__++] = (value); \ - } while (cv_sz__ < cv_sz_count__); \ - } \ - else { \ - while (cv_sz_count__ < cv_sz__--) { \ - cvector_pop_back(vec); \ - } \ - } \ - } \ +#define cvector_resize(vec, count, value) \ + do { \ + if (vec) { \ + size_t cv_sz_count__ = (size_t)(count); \ + size_t cv_sz__ = cvector_vec_to_base(vec)->size; \ + if (cv_sz_count__ > cv_sz__) { \ + cvector_reserve((vec), cv_sz_count__); \ + cvector_set_size((vec), cv_sz_count__); \ + do { \ + (vec)[cv_sz__++] = (value); \ + } while (cv_sz__ < cv_sz_count__); \ + } else { \ + while (cv_sz_count__ < cv_sz__--) { \ + cvector_pop_back(vec); \ + } \ + } \ + } \ } while (0) #endif /* CVECTOR_H_ */