1
0
Fork 0
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:
Yuxuan Shui 2024-06-04 19:45:17 +01:00
parent 5e16eeddd8
commit c2cb4df94a
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4

View file

@ -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); \