From 3efa356bb8b09ca7406b51c38b0d0ee7ad0c82d7 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 21 Nov 2013 16:25:01 -0500 Subject: [PATCH] Revert "Add double-free detection code to the pools" This reverts commit 9cdcfd2522febcc2eb7f65d926a37cfa05f21323. --- .../nvstream/av/AvByteBufferPool.java | 18 +----------------- .../limelight/nvstream/av/AvObjectPool.java | 17 +---------------- .../nvstream/av/AvShortBufferPool.java | 18 +----------------- 3 files changed, 3 insertions(+), 50 deletions(-) diff --git a/src/com/limelight/nvstream/av/AvByteBufferPool.java b/src/com/limelight/nvstream/av/AvByteBufferPool.java index 0fe652af..1da5e6ad 100644 --- a/src/com/limelight/nvstream/av/AvByteBufferPool.java +++ b/src/com/limelight/nvstream/av/AvByteBufferPool.java @@ -6,8 +6,6 @@ public class AvByteBufferPool { private ConcurrentLinkedQueue bufferList = new ConcurrentLinkedQueue(); private int bufferSize; - private static final boolean doubleFreeDebug = true; - public AvByteBufferPool(int size) { this.bufferSize = size; @@ -20,13 +18,7 @@ public class AvByteBufferPool { public byte[] allocate() { - byte[] buff; - if (doubleFreeDebug) { - buff = null; - } - else { - buff = bufferList.poll(); - } + byte[] buff = bufferList.poll(); if (buff == null) { buff = new byte[bufferSize]; } @@ -35,14 +27,6 @@ public class AvByteBufferPool { public void free(byte[] buffer) { - if (doubleFreeDebug) { - for (byte[] buf : bufferList) { - if (buf == buffer) { - throw new IllegalStateException("Double free detected"); - } - } - } - bufferList.add(buffer); } } diff --git a/src/com/limelight/nvstream/av/AvObjectPool.java b/src/com/limelight/nvstream/av/AvObjectPool.java index d751be98..97de612c 100644 --- a/src/com/limelight/nvstream/av/AvObjectPool.java +++ b/src/com/limelight/nvstream/av/AvObjectPool.java @@ -5,8 +5,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; public class AvObjectPool { private ConcurrentLinkedQueue objectList = new ConcurrentLinkedQueue(); - private static final boolean doubleFreeDebug = true; - public void purge() { objectList.clear(); @@ -14,24 +12,11 @@ public class AvObjectPool { public T tryAllocate() { - if (doubleFreeDebug) { - return null; - } - else { - return objectList.poll(); - } + return objectList.poll(); } public void free(T object) { - if (doubleFreeDebug) { - for (T obj : objectList) { - if (obj == object) { - throw new IllegalStateException("Double free detected"); - } - } - } - objectList.add(object); } } diff --git a/src/com/limelight/nvstream/av/AvShortBufferPool.java b/src/com/limelight/nvstream/av/AvShortBufferPool.java index 9f7a956c..012383f8 100644 --- a/src/com/limelight/nvstream/av/AvShortBufferPool.java +++ b/src/com/limelight/nvstream/av/AvShortBufferPool.java @@ -6,8 +6,6 @@ public class AvShortBufferPool { private ConcurrentLinkedQueue bufferList = new ConcurrentLinkedQueue(); private int bufferSize; - private static final boolean doubleFreeDebug = true; - public AvShortBufferPool(int size) { this.bufferSize = size; @@ -20,13 +18,7 @@ public class AvShortBufferPool { public short[] allocate() { - short[] buff; - if (doubleFreeDebug) { - buff = null; - } - else { - buff = bufferList.poll(); - } + short[] buff = bufferList.poll(); if (buff == null) { buff = new short[bufferSize]; } @@ -35,14 +27,6 @@ public class AvShortBufferPool { public void free(short[] buffer) { - if (doubleFreeDebug) { - for (short[] buf : bufferList) { - if (buf == buffer) { - throw new IllegalStateException("Double free detected"); - } - } - } - bufferList.add(buffer); } }