| 801 | */ |
| 802 | |
| 803 | void UArray_insert_every_(UArray *self, UArray *other, size_t itemCount) { |
| 804 | UArray *out = UArray_new(); |
| 805 | UArray *convertedOther = other; |
| 806 | |
| 807 | if (itemCount == 0) { |
| 808 | UArray_error_(self, "UArray_insert_every_: itemCount must be > 0"); |
| 809 | return; |
| 810 | } |
| 811 | |
| 812 | if (UArray_itemType(self) != UArray_itemType(other)) { |
| 813 | UArray *convertedOther = UArray_clone(other); |
| 814 | UArray_convertToItemType_(convertedOther, UArray_itemType(self)); |
| 815 | } |
| 816 | |
| 817 | { |
| 818 | size_t selfSizeInBytes = UArray_sizeInBytes(self); |
| 819 | size_t otherSize = UArray_size(convertedOther); |
| 820 | size_t chunkSize = itemCount * UArray_itemSize(self); |
| 821 | size_t i; |
| 822 | |
| 823 | for (i = 0; i < selfSizeInBytes; i += chunkSize) { |
| 824 | if (i + chunkSize > selfSizeInBytes) { |
| 825 | UArray_appendBytes_size_(out, self->data + i, |
| 826 | selfSizeInBytes - i); |
| 827 | } else { |
| 828 | UArray_appendBytes_size_(out, self->data + i, chunkSize); |
| 829 | UArray_appendBytes_size_(out, convertedOther->data, otherSize); |
| 830 | } |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | if (UArray_itemType(self) != UArray_itemType(other)) { |
| 835 | UArray_free(convertedOther); |
| 836 | } |
| 837 | |
| 838 | UArray_copy_(self, out); |
| 839 | UArray_free(out); |
| 840 | } |
| 841 | |
| 842 | void UArray_at_putAll_(UArray *self, size_t pos, const UArray *other) { |
| 843 | if (other->size == 0) |
no test coverage detected