File tree Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public int Size
2020 get => data . Length ;
2121 set
2222 {
23- if ( value != data . Length )
23+ if ( value >= 0 && value != data . Length )
2424 {
2525 data = new byte [ value ] ;
2626 historyData = new byte [ value ] ;
@@ -44,20 +44,12 @@ private void ObjectInvariants()
4444 }
4545
4646 public MemoryBuffer ( )
47- : this ( 0 )
4847 {
4948 Contract . Ensures ( data != null ) ;
5049 Contract . Ensures ( historyData != null ) ;
51- }
52-
53- public MemoryBuffer ( int size )
54- {
55- Contract . Requires ( size >= 0 ) ;
56- Contract . Ensures ( data != null ) ;
57- Contract . Ensures ( historyData != null ) ;
5850
59- data = new byte [ size ] ;
60- historyData = new byte [ size ] ;
51+ data = Array . Empty < byte > ( ) ;
52+ historyData = Array . Empty < byte > ( ) ;
6153 }
6254
6355 public MemoryBuffer ( MemoryBuffer other )
Original file line number Diff line number Diff line change 1- using System ;
1+ using System ;
22using System . Text ;
33using NFluent ;
44using ReClassNET . Memory ;
@@ -10,7 +10,10 @@ public class MemoryBufferTest
1010 {
1111 private static MemoryBuffer CreateFromBytes ( params byte [ ] data )
1212 {
13- var buffer = new MemoryBuffer ( data . Length ) ;
13+ var buffer = new MemoryBuffer
14+ {
15+ Size = data . Length
16+ } ;
1417 Array . Copy ( data , buffer . RawData , data . Length ) ;
1518 return buffer ;
1619 }
You can’t perform that action at this time.
0 commit comments