diff --git a/src/resizable.c b/src/resizable.c index 7bb642f..ff038b3 100644 --- a/src/resizable.c +++ b/src/resizable.c @@ -215,15 +215,28 @@ apfl_resizable_splice( bool apfl_resizable_append(struct apfl_allocator allocator, size_t elem_size, void **mem, size_t *len, size_t *cap, const void *other_mem, size_t other_len) { - return apfl_resizable_splice( + if (other_len == 0 || other_mem == NULL) { + return true; + } + + if (!apfl_resizable_ensure_cap_for_more_elements( allocator, elem_size, mem, - len, - cap, *len, - 0, - other_mem, + cap, other_len + )) { + return false; + } + + memcpy( + ((char *)(*mem)) + *len * elem_size, + other_mem, + other_len * elem_size ); + + *len += other_len; + + return true; }