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
20
20
get => data . Length ;
21
21
set
22
22
{
23
- if ( value != data . Length )
23
+ if ( value >= 0 && value != data . Length )
24
24
{
25
25
data = new byte [ value ] ;
26
26
historyData = new byte [ value ] ;
@@ -44,20 +44,12 @@ private void ObjectInvariants()
44
44
}
45
45
46
46
public MemoryBuffer ( )
47
- : this ( 0 )
48
47
{
49
48
Contract . Ensures ( data != null ) ;
50
49
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 ) ;
58
50
59
- data = new byte [ size ] ;
60
- historyData = new byte [ size ] ;
51
+ data = Array . Empty < byte > ( ) ;
52
+ historyData = Array . Empty < byte > ( ) ;
61
53
}
62
54
63
55
public MemoryBuffer ( MemoryBuffer other )
Original file line number Diff line number Diff line change 1
- using System ;
1
+ using System ;
2
2
using System . Text ;
3
3
using NFluent ;
4
4
using ReClassNET . Memory ;
@@ -10,7 +10,10 @@ public class MemoryBufferTest
10
10
{
11
11
private static MemoryBuffer CreateFromBytes ( params byte [ ] data )
12
12
{
13
- var buffer = new MemoryBuffer ( data . Length ) ;
13
+ var buffer = new MemoryBuffer
14
+ {
15
+ Size = data . Length
16
+ } ;
14
17
Array . Copy ( data , buffer . RawData , data . Length ) ;
15
18
return buffer ;
16
19
}
You can’t perform that action at this time.
0 commit comments