diff options
author | pommicket <pommicket@gmail.com> | 2023-08-15 10:56:34 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-15 10:56:34 -0400 |
commit | 2515bf34a97620ffbfcf5db8451c422ccf132cf8 (patch) | |
tree | 4758ae1fe8aad9c9ba905913d586710795ee6a59 /ds.h | |
parent | ad8c5d1466eb8edf2e6343f28026ae993ac31f2c (diff) |
fix iwndows build
Diffstat (limited to 'ds.h')
-rw-r--r-- | ds.h | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -222,11 +222,14 @@ static i32 arr_index_of_(void *arr, size_t member_size, const void *item) { static void *arr_remove_multiple_(void *arr, size_t member_size, size_t index, size_t count) { ArrHeader *hdr = arr_hdr_(arr); - assert(index < hdr->len); + u32 old_len = hdr->len; + if (index >= old_len) return arr; + if (count > old_len - index) + count = old_len - index; memmove((char *)arr + index * member_size, (char *)arr + (index + count) * member_size, (hdr->len - (index + count)) * member_size); - hdr->len -= count; + hdr->len -= (u32)count; if (hdr->len == 0) { free(hdr); return NULL; |