diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-10-16 08:19:47 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-10-16 08:19:47 +0200 |
commit | f3178067bb6963aa913dfd9a024e960729056760 (patch) | |
tree | bb2d0ca04035cb497748ba17364a10c48788f844 /include | |
parent | 1781e5937a6e200e3627d482bee6ccb919444568 (diff) |
Take a pointer to a pointer
Diffstat (limited to 'include')
-rw-r--r-- | include/array.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/include/array.h b/include/array.h index 0853c2d..ba7fa8d 100644 --- a/include/array.h +++ b/include/array.h @@ -34,22 +34,22 @@ _mlib_array_hdr(void *p, ptrdiff_t align) #define array_push(p, x) \ do { \ - _mlib_arr_hdr_t *hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \ + _mlib_arr_hdr_t *hdr = _mlib_array_hdr(*(p), alignof(typeof(**(p)))); \ if (hdr->len == hdr->cap) { \ - (p) = array_resz((p), hdr->len * 2); \ - hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \ + *(p) = array_resz(*(p), hdr->len * 2); \ + hdr = _mlib_array_hdr(*(p), alignof(typeof(**(p)))); \ } \ - (p)[hdr->len++] = (x); \ + (*(p))[hdr->len++] = (x); \ } while (false) #define array_extend(p, xs, n) \ do { \ - _mlib_arr_hdr_t *hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \ + _mlib_arr_hdr_t *hdr = _mlib_array_hdr(*(p), alignof(typeof(**(p)))); \ if (hdr->len + (n) >= hdr->cap) { \ - (p) = array_resz((p), stdc_bit_ceil((size_t)hdr->len + (n))); \ - hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \ + *(p) = array_resz(*(p), stdc_bit_ceil((size_t)hdr->len + (n))); \ + hdr = _mlib_array_hdr(*(p), alignof(typeof(**(p)))); \ } \ - memcpy(&(p)[hdr->len], (xs), (n) * sizeof(*xs)); \ + memcpy(&(*(p))[hdr->len], (xs), (n) * sizeof(*xs)); \ hdr->len += (n); \ } while (false) |