diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-05-10 23:47:31 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-05-10 23:47:31 +0200 |
commit | b04989164df973eaf6565d1c9bf2505215a54604 (patch) | |
tree | 44d49cc803cc00b534e14a701bca7b8ebce90c2e /lib/dynarr/dapush.c | |
parent | 4f62899af7e97501ec081f9268d80ebf87150c2a (diff) |
Add daextend() to the new dynarr system
Diffstat (limited to 'lib/dynarr/dapush.c')
-rw-r--r-- | lib/dynarr/dapush.c | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/lib/dynarr/dapush.c b/lib/dynarr/dapush.c deleted file mode 100644 index 11fde1b..0000000 --- a/lib/dynarr/dapush.c +++ /dev/null @@ -1,22 +0,0 @@ -#include <errno.h> -#include <stdbit.h> -#include <stdint.h> -#include <string.h> - -#include "dynarr.h" - -void * -(dapush)(void *da, void *x, size_t sz, size_t align) -{ - dynarr(uint8_t) cpy; - memcpy(&cpy, da, sizeof(cpy)); - - if (++cpy.len > cpy.cap) { - size_t ncap = stdc_bit_ceil(cpy.len); - cpy.buf = cpy.alloc(cpy.ctx, cpy.buf, cpy.cap, ncap, sz, align); - cpy.cap = ncap; - } - - memcpy(cpy.buf + cpy.len * sz - sz, x, sz); - return memcpy(da, &cpy, sizeof(cpy)); -} |