/*** * linserts.c */ #include #include #include #include "./allocator.h" #include "./vector.h" int32_t linserts(void *dest, const size_t length, const size_t num, const size_t size, const size_t index, const void *items, const size_t count) { /* if list isn't large enough, fail */ if ((length - num) < count) { return (VEC_ERR_NOSPACE); } /* shift data to the right */ if (index < num) { memmove(VECITEM(dest, index + count, size), VECITEM(dest, index, size), size * (num - index)); } memcpy(VECITEM(dest, index, size), items, count * size); return (VEC_OKAY); }