diff options
author | pommicket <pommicket@gmail.com> | 2023-01-03 15:38:54 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-01-03 15:38:54 -0500 |
commit | baae904ed2c97ba5c701442ec5ef6900715f785d (patch) | |
tree | 6e6c10265624510dd73bb8bd0213a59fc02e3617 /ds.h | |
parent | c37d493327ded5952f46cbf39aef920e47c1d7d9 (diff) |
switch from scancodes to keycodes
Diffstat (limited to 'ds.h')
-rw-r--r-- | ds.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -192,6 +192,13 @@ static void *arr_remove_(void *arr, size_t member_size, size_t index) { } } +static void *arr_copy_(const void *arr, size_t member_size) { + void *new_arr = NULL; + arr_set_len_(&new_arr, member_size, arr_len(arr)); + memcpy(new_arr, arr, member_size * arr_len(arr)); + return new_arr; +} + #ifdef __cplusplus #define arr_cast_typeof(a) (decltype(a)) #elif defined __GNUC__ @@ -224,6 +231,7 @@ static void *arr_remove_(void *arr, size_t member_size, size_t index) { #define arr_pop_last(a) ((a)[--arr_hdr_(a)->len]) #define arr_size_in_bytes(a) (arr_len(a) * sizeof *(a)) #define arr_lastp(a) ((a) ? &(a)[arr_len(a)-1] : NULL) +#define arr_copy(a) arr_cast_typeof(a) arr_copy_((a), sizeof *(a)) #define arr_foreach_ptr_end(a, type, var, end) type *end = (a) + arr_len(a); \ for (type *var = (a); var != end; ++var) // Iterate through each element of the array, setting var to a pointer to the element. |