Skip to content

Commit 7f890e1

Browse files
committed
Removed unused constructor.
Prevent negative size.
1 parent 6547cc1 commit 7f890e1

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

ReClass.NET/Memory/MemoryBuffer.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff 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)

ReClass.NET_Tests/Memory/MemoryBufferTest.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Text;
33
using NFluent;
44
using 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
}

0 commit comments

Comments
 (0)