diff --git a/BeefLibs/corlib/src/Array.bf b/BeefLibs/corlib/src/Array.bf index 1a1d5b2d..122c35d9 100644 --- a/BeefLibs/corlib/src/Array.bf +++ b/BeefLibs/corlib/src/Array.bf @@ -277,7 +277,7 @@ namespace System Debug.Assert(length >= 0); Debug.Assert((uint)srcOffset + (uint)length <= (uint)mLength); Debug.Assert((uint)dstOffset + (uint)length <= (uint)arrayTo.mLength); - Internal.MemCpy(&arrayTo.GetRef(dstOffset), &GetRef(srcOffset), strideof(T) * length, alignof(T)); + Internal.MemMove(&arrayTo.GetRef(dstOffset), &GetRef(srcOffset), strideof(T) * length, alignof(T)); } public void CopyTo(T2[] arrayTo, int srcOffset, int dstOffset, int length) where T2 : operator explicit T @@ -300,17 +300,18 @@ namespace System public void CopyTo(Span destination) { Debug.Assert(destination.[Friend]mLength >= mLength); - Internal.MemCpy(destination.Ptr, &GetRef(0), strideof(T) * mLength, alignof(T)); + Internal.MemMove(destination.Ptr, &GetRef(0), strideof(T) * mLength, alignof(T)); } public void CopyTo(Span destination, int srcOffset) { Debug.Assert((uint)srcOffset + (uint)destination.[Friend]mLength <= (uint)mLength); - Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * (destination.[Friend]mLength - srcOffset), alignof(T)); + Internal.MemMove(destination.Ptr, &GetRef(srcOffset), strideof(T) * (destination.[Friend]mLength - srcOffset), alignof(T)); } public void CopyTo(Span destination, int srcOffset) where T2 : operator explicit T { + //TODO: Handle src/dest overlap (MemMove) Debug.Assert((uint)srcOffset + (uint)destination.[Friend]mLength <= (uint)mLength); var ptr = destination.[Friend]mPtr; for (int i = 0; i < destination.[Friend]mLength; i++) diff --git a/BeefLibs/corlib/src/Collections/List.bf b/BeefLibs/corlib/src/Collections/List.bf index 800f5380..e2445326 100644 --- a/BeefLibs/corlib/src/Collections/List.bf +++ b/BeefLibs/corlib/src/Collections/List.bf @@ -535,7 +535,7 @@ namespace System.Collections if (mSize == AllocSize) EnsureCapacity(mSize + 1, true); if (index < mSize) { - Internal.MemCpy(mItems + index + 1, mItems + index, (mSize - index) * strideof(T), alignof(T)); + Internal.MemMove(mItems + index + 1, mItems + index, (mSize - index) * strideof(T), alignof(T)); } mItems[index] = item; mSize++; @@ -554,7 +554,7 @@ namespace System.Collections if (mSize + addCount > AllocSize) EnsureCapacity(mSize + addCount, true); if (index < mSize) { - Internal.MemCpy(mItems + index + addCount, mItems + index, (mSize - index) * strideof(T), alignof(T)); + Internal.MemMove(mItems + index + addCount, mItems + index, (mSize - index) * strideof(T), alignof(T)); } Internal.MemCpy(mItems + index, items.Ptr, addCount * strideof(T)); mSize += (int_cosize)addCount; @@ -568,7 +568,7 @@ namespace System.Collections Debug.Assert((uint)index < (uint)mSize); if (index < mSize - 1) { - Internal.MemCpy(mItems + index, mItems + index + 1, (mSize - index - 1) * strideof(T), alignof(T)); + Internal.MemMove(mItems + index, mItems + index + 1, (mSize - index - 1) * strideof(T), alignof(T)); } mSize--; #if VERSION_LIST