Implemented filling dynamics arrays with normal array data

This commit is contained in:
cannoli-fruit 2026-07-15 23:58:18 -04:00
commit 0722bcf51b
2 changed files with 27 additions and 0 deletions

11
lazy.h
View file

@ -130,6 +130,17 @@ long long lz_slc_atoll(Lz_Slc *src);
for (T *name = (da).data; name-(da).data < (da).cnt; ++name)
#endif
#ifndef lz_da_fill_from_array
#define lz_da_fill_from_array(p_da, arr) do {\
free((p_da)->data);\
size_t cnt = sizeof(arr)/sizeof(*arr);\
(p_da)->cap = cnt;\
(p_da)->cnt = cnt;\
(p_da)->data = malloc(sizeof(arr));\
memcpy((p_da)->data, arr, sizeof(arr));\
} while(0)
#endif
#ifndef LZ_SB_DEFINITION
#define LZ_SB_DEFINITION
typedef Lz_DA(char) Lz_SB;