mirror of
https://github.com/yshui/picom.git
synced 2025-04-14 17:53:25 -04:00
utils/dynarr: fix dynarr_resize
It was reserving wrong number of elements. dynarr_reserve reserves on top of existing len, not existing cap. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
5e16eeddd8
commit
c2cb4df94a
1 changed files with 1 additions and 3 deletions
|
@ -86,9 +86,7 @@ static inline void dynarr_remove_swap_impl(size_t size, void *arr, size_t idx) {
|
|||
#define dynarr_resize(arr, newlen, init, dtor) \
|
||||
do { \
|
||||
BUG_ON((arr) == NULL); \
|
||||
if ((newlen) > dynarr_cap(arr)) { \
|
||||
dynarr_reserve((arr), (newlen)-dynarr_cap(arr)); \
|
||||
} \
|
||||
dynarr_reserve((arr), (newlen)-dynarr_len(arr)); \
|
||||
if ((init) != NULL) { \
|
||||
for (size_t i = dynarr_len(arr); i < (newlen); i++) { \
|
||||
(init)((arr) + i); \
|
||||
|
|
Loading…
Add table
Reference in a new issue