MCPcopy Create free account
hub / github.com/IoLanguage/io / UArray_insert_every_

Function UArray_insert_every_

libs/basekit/source/UArray.c:803–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

801*/
802
803void 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
842void UArray_at_putAll_(UArray *self, size_t pos, const UArray *other) {
843 if (other->size == 0)

Callers 1

IoSeq_mutable.cFile · 0.85

Calls 11

UArray_newFunction · 0.85
UArray_error_Function · 0.85
UArray_itemTypeFunction · 0.85
UArray_cloneFunction · 0.85
UArray_sizeInBytesFunction · 0.85
UArray_sizeFunction · 0.85
UArray_itemSizeFunction · 0.85
UArray_appendBytes_size_Function · 0.85
UArray_freeFunction · 0.85
UArray_copy_Function · 0.85

Tested by

no test coverage detected