commit c052684fcd2be31c18dde6c50af5b577c2cac55b
parent 5b11e106e45c2f5dc57291d6f4ebff4317bed1f4
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Tue, 30 Aug 2011 12:16:46 -0400
Util: added dellocator to memory pool
- used to remove memory leak detections in valgrind
Diffstat:
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
@@ -24,6 +24,7 @@
#include <vector>
#include <math.h>
#include <stdio.h>
+#include <err.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -186,4 +187,14 @@ void returnTmpBuffer(float *buf)
fprintf(stderr,"ERROR: invalid buffer returned %s %d\n",__FILE__,__LINE__);
}
+void clearTmpBuffers(void)
+{
+ for(pool_itr_t itr = pool.begin(); itr != pool.end(); ++itr) {
+ if(!itr->free) //Warn about used buffers
+ warn("Temporary buffer (%p) about to be freed may be in use", itr->dat);
+ delete [] itr->dat;
+ }
+ pool.clear();
+}
+
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
@@ -60,6 +60,7 @@ void invSignal(float *sig, size_t len);
//All should be sized to SOUND_BUFFER_SIZE
float *getTmpBuffer();
void returnTmpBuffer(float *buf);
+void clearTmpBuffers(void);
template<class T>
std::string stringFrom(T x)
diff --git a/src/Tests/SubNoteTest.h b/src/Tests/SubNoteTest.h
@@ -82,6 +82,7 @@ class SubNoteTest:public CxxTest::TestSuite
delete [] outL;
delete [] outR;
delete [] denormalkillbuf;
+ clearTmpBuffers();
}
void testDefaults() {