mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Revert "Add double-free detection code to the pools"
This reverts commit 9cdcfd2522febcc2eb7f65d926a37cfa05f21323.
This commit is contained in:
parent
45120e79e4
commit
3efa356bb8
@ -6,8 +6,6 @@ public class AvByteBufferPool {
|
|||||||
private ConcurrentLinkedQueue<byte[]> bufferList = new ConcurrentLinkedQueue<byte[]>();
|
private ConcurrentLinkedQueue<byte[]> bufferList = new ConcurrentLinkedQueue<byte[]>();
|
||||||
private int bufferSize;
|
private int bufferSize;
|
||||||
|
|
||||||
private static final boolean doubleFreeDebug = true;
|
|
||||||
|
|
||||||
public AvByteBufferPool(int size)
|
public AvByteBufferPool(int size)
|
||||||
{
|
{
|
||||||
this.bufferSize = size;
|
this.bufferSize = size;
|
||||||
@ -20,13 +18,7 @@ public class AvByteBufferPool {
|
|||||||
|
|
||||||
public byte[] allocate()
|
public byte[] allocate()
|
||||||
{
|
{
|
||||||
byte[] buff;
|
byte[] buff = bufferList.poll();
|
||||||
if (doubleFreeDebug) {
|
|
||||||
buff = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buff = bufferList.poll();
|
|
||||||
}
|
|
||||||
if (buff == null) {
|
if (buff == null) {
|
||||||
buff = new byte[bufferSize];
|
buff = new byte[bufferSize];
|
||||||
}
|
}
|
||||||
@ -35,14 +27,6 @@ public class AvByteBufferPool {
|
|||||||
|
|
||||||
public void free(byte[] buffer)
|
public void free(byte[] buffer)
|
||||||
{
|
{
|
||||||
if (doubleFreeDebug) {
|
|
||||||
for (byte[] buf : bufferList) {
|
|
||||||
if (buf == buffer) {
|
|
||||||
throw new IllegalStateException("Double free detected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bufferList.add(buffer);
|
bufferList.add(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
public class AvObjectPool<T> {
|
public class AvObjectPool<T> {
|
||||||
private ConcurrentLinkedQueue<T> objectList = new ConcurrentLinkedQueue<T>();
|
private ConcurrentLinkedQueue<T> objectList = new ConcurrentLinkedQueue<T>();
|
||||||
|
|
||||||
private static final boolean doubleFreeDebug = true;
|
|
||||||
|
|
||||||
public void purge()
|
public void purge()
|
||||||
{
|
{
|
||||||
objectList.clear();
|
objectList.clear();
|
||||||
@ -14,24 +12,11 @@ public class AvObjectPool<T> {
|
|||||||
|
|
||||||
public T tryAllocate()
|
public T tryAllocate()
|
||||||
{
|
{
|
||||||
if (doubleFreeDebug) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return objectList.poll();
|
return objectList.poll();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void free(T object)
|
public void free(T object)
|
||||||
{
|
{
|
||||||
if (doubleFreeDebug) {
|
|
||||||
for (T obj : objectList) {
|
|
||||||
if (obj == object) {
|
|
||||||
throw new IllegalStateException("Double free detected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
objectList.add(object);
|
objectList.add(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,6 @@ public class AvShortBufferPool {
|
|||||||
private ConcurrentLinkedQueue<short[]> bufferList = new ConcurrentLinkedQueue<short[]>();
|
private ConcurrentLinkedQueue<short[]> bufferList = new ConcurrentLinkedQueue<short[]>();
|
||||||
private int bufferSize;
|
private int bufferSize;
|
||||||
|
|
||||||
private static final boolean doubleFreeDebug = true;
|
|
||||||
|
|
||||||
public AvShortBufferPool(int size)
|
public AvShortBufferPool(int size)
|
||||||
{
|
{
|
||||||
this.bufferSize = size;
|
this.bufferSize = size;
|
||||||
@ -20,13 +18,7 @@ public class AvShortBufferPool {
|
|||||||
|
|
||||||
public short[] allocate()
|
public short[] allocate()
|
||||||
{
|
{
|
||||||
short[] buff;
|
short[] buff = bufferList.poll();
|
||||||
if (doubleFreeDebug) {
|
|
||||||
buff = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buff = bufferList.poll();
|
|
||||||
}
|
|
||||||
if (buff == null) {
|
if (buff == null) {
|
||||||
buff = new short[bufferSize];
|
buff = new short[bufferSize];
|
||||||
}
|
}
|
||||||
@ -35,14 +27,6 @@ public class AvShortBufferPool {
|
|||||||
|
|
||||||
public void free(short[] buffer)
|
public void free(short[] buffer)
|
||||||
{
|
{
|
||||||
if (doubleFreeDebug) {
|
|
||||||
for (short[] buf : bufferList) {
|
|
||||||
if (buf == buffer) {
|
|
||||||
throw new IllegalStateException("Double free detected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bufferList.add(buffer);
|
bufferList.add(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user