File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Src/StackMemoryCollections Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -1001,13 +1001,18 @@ bool calculateSize
10011001 ) where T : unmanaged
10021002 {
10031003 builder . Append ( $@ "
1004- public void Copy(in void* ptrDest, in int count)
1004+ public void Copy(in void* ptrDest, in nuint count)
10051005 {{
1006+ if(Size < (nuint)count)
1007+ {{
1008+ throw new Exception(""The collection does not have that many elements"");
1009+ }}
1010+
10061011 Buffer.MemoryCopy(
10071012 _start,
10081013 ptrDest,
1009- count * { ( calculateSize ? $ "sizeof({ typeof ( T ) . Name } )" : ( sizeOf ) . ToString ( ) ) } ,
1010- count * { ( calculateSize ? $ "sizeof({ typeof ( T ) . Name } )" : ( sizeOf ) . ToString ( ) ) }
1014+ count * (nuint) { ( calculateSize ? $ "sizeof({ typeof ( T ) . Name } )" : ( sizeOf ) . ToString ( ) ) } ,
1015+ count * (nuint) { ( calculateSize ? $ "sizeof({ typeof ( T ) . Name } )" : ( sizeOf ) . ToString ( ) ) }
10111016 );
10121017 }}
10131018" ) ;
@@ -1022,6 +1027,11 @@ bool calculateSize
10221027 builder . Append ( $@ "
10231028 public void Copy(in void* ptrDest)
10241029 {{
1030+ if(Size == 0)
1031+ {{
1032+ return;
1033+ }}
1034+
10251035 Buffer.MemoryCopy(
10261036 _start,
10271037 ptrDest,
Original file line number Diff line number Diff line change @@ -1023,6 +1023,11 @@ in string sizeOfStr
10231023 builder . Append ( $@ "
10241024 public void Copy(in void* ptrDest)
10251025 {{
1026+ if(Size == 0)
1027+ {{
1028+ return;
1029+ }}
1030+
10261031 Buffer.MemoryCopy(
10271032 _start,
10281033 ptrDest,
@@ -1041,6 +1046,11 @@ in string sizeOfStr
10411046 builder . Append ( $@ "
10421047 public void Copy(in void* ptrDest, in nuint count)
10431048 {{
1049+ if(Size < count)
1050+ {{
1051+ throw new Exception(""The collection does not have that many elements"");
1052+ }}
1053+
10441054 Buffer.MemoryCopy(
10451055 _start,
10461056 ptrDest,
You can’t perform that action at this time.
0 commit comments