summaryrefslogtreecommitdiff
path: root/source/kit/dynamic_array.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/kit/dynamic_array.h')
-rw-r--r--source/kit/dynamic_array.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/kit/dynamic_array.h b/source/kit/dynamic_array.h
index d9c3f87..409e7df 100644
--- a/source/kit/dynamic_array.h
+++ b/source/kit/dynamic_array.h
@@ -55,11 +55,11 @@ void kit_da_resize(kit_da_void_t *array, ptrdiff_t element_size,
/* Destroy dynamic array.
*/
#define KIT_DA_DESTROY(array_) \
- { \
+ do { \
if ((array_).values != NULL) \
(array_).alloc.deallocate((array_).alloc.state, \
(array_).values); \
- }
+ } while (0)
/* Resize dynamic array.
*/
@@ -70,17 +70,17 @@ void kit_da_resize(kit_da_void_t *array, ptrdiff_t element_size,
/* Append a value to dynamic array.
*/
#define KIT_DA_APPEND(array_, value_) \
- { \
+ do { \
ptrdiff_t const kit_index_back_ = (array_).size; \
KIT_DA_RESIZE((array_), kit_index_back_ + 1); \
if (kit_index_back_ < (array_).size) \
(array_).values[kit_index_back_] = (value_); \
- }
+ } while (0)
/* Insert a value into dynamic array.
*/
#define KIT_DA_INSERT(array_, index_, value_) \
- { \
+ do { \
ptrdiff_t const kit_index_back_ = (array_).size; \
ptrdiff_t const kit_indert_n_ = (index_); \
KIT_DA_RESIZE((array_), kit_index_back_ + 1); \
@@ -90,16 +90,16 @@ void kit_da_resize(kit_da_void_t *array, ptrdiff_t element_size,
(array_).values[kit_i_] = (array_).values[kit_i_ - 1]; \
(array_).values[kit_indert_n_] = (value_); \
} \
- }
+ } while (0)
/* Erase a value from dynamic array.
*/
#define KIT_DA_ERASE(array_, index_) \
- { \
+ do { \
for (ptrdiff_t i_ = (index_) + 1; i_ < (array_).size; i_++) \
(array_).values[i_ - 1] = (array_).values[i_]; \
KIT_DA_RESIZE((array_), (array_).size - 1); \
- }
+ } while (0)
#ifndef KIT_DISABLE_SHORT_NAMES
# define da_void_t kit_da_void_t