rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 01ac7c6e899db34aa4eaa34476a28325bd4a7431
parent e74df4f6cbd2cfe496b70e24b92704ac5998d5d0
Author: vaplv <vaplv@free.fr>
Date:   Fri, 15 Mar 2019 09:38:51 +0100

Add the DARRAY_BUF helper macro

Diffstat:
Msrc/dynamic_array.h | 3+++
Msrc/test_dynamic_array.c | 4++++
2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/dynamic_array.h b/src/dynamic_array.h @@ -22,6 +22,9 @@ #include "rsys.h" #include <string.h> +/* Helper macro to quickly access darray internal buffer */ +#define DARRAY_BUF(Darray) (Darray)->data + #endif /* DYNAMIC_ARRAY_H */ #else /* diff --git a/src/test_dynamic_array.c b/src/test_dynamic_array.c @@ -73,7 +73,11 @@ test_cstr(struct mem_allocator* allocator) darray_str_push_back(&darray, strs + i); } FOR_EACH(i, 0, nstrs) { + CHK(DARRAY_BUF(&darray) == darray_str_cdata_get(&darray)); + CHK(DARRAY_BUF(&darray) == darray_str_data_get(&darray)); + CHK(DARRAY_BUF((struct darray_str*)(&darray)) == DARRAY_BUF(&darray)); CHK(strcmp(darray_str_cdata_get(&darray)[i], strs[i]) == 0); + CHK(strcmp(DARRAY_BUF(&darray)[i], strs[i]) == 0); } darray_str_purge(&darray); CHK(darray_str_size_get(&darray) == 0);