From 974ba3a08a427443369461cbb1196fa7d5b67c04 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 14 Mar 2006 17:13:44 +0000 Subject: fixed faulty assertion fixed buggy memory deallocation for AtomListStatic svn path=/trunk/; revision=4706 --- externals/grill/flext/build.txt | 2 ++ externals/grill/flext/changes.txt | 1 + externals/grill/flext/flext.vcproj | 2 +- externals/grill/flext/source/flatom.cpp | 37 ++++++++++++++++++++++++++------- 4 files changed, 34 insertions(+), 8 deletions(-) (limited to 'externals/grill/flext') diff --git a/externals/grill/flext/build.txt b/externals/grill/flext/build.txt index 92fdab7c..640b1c04 100644 --- a/externals/grill/flext/build.txt +++ b/externals/grill/flext/build.txt @@ -130,12 +130,14 @@ or buildsys/config-mac-max-gcc.txt +After editing the files you will have to run the build script again to ensure that flext is built. After successfully building everything, you can install flext with (under Windows) build pd msvc install or (under unix) bash build.sh pd gcc install + You will probably have to have superuser rights in order to install things into the default location. (try "sudo" or "su -c" prefixes, or log in as root) diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index 38320249..c2437720 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -26,6 +26,7 @@ Version history: - fixing uninitialized pointer (first inlet pointer) - added message bundle functionality (to send more messages over the thread boundary to arrive at the same logical time) - fixed dangerous spot (also memory leak) with message queuing +- fixed buggy freeing of memory for AtomListStatic 0.5.0: - fixes for 64 bit builds (size_t is integer type of pointer size) diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj index 3eaa1c6b..f8d6a3da 100644 --- a/externals/grill/flext/flext.vcproj +++ b/externals/grill/flext/flext.vcproj @@ -122,7 +122,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="c:\data\prog\packs\pthreads\include;"c:\data\pd\pd-cvs\src";c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS_PD;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_EXPORTS;xFLEXT_ATTRHIDE;xFLEXT_NOATTREDIT;_WIN32_WINNT=0x501" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS_PD;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_EXPORTS;xFLEXT_ATTRHIDE;xFLEXT_NOATTREDIT;_WIN32_WINNT=0x501;xFLEXT_USECMEM" BasicRuntimeChecks="3" RuntimeLibrary="1" RuntimeTypeInfo="TRUE" diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp index 9f433222..b8853aca 100644 --- a/externals/grill/flext/source/flatom.cpp +++ b/externals/grill/flext/source/flatom.cpp @@ -61,19 +61,32 @@ void flext::CopyAtoms(int cnt,t_atom *dst,const t_atom *src) void flext::AtomList::Alloc(int sz,int keepix,int keeplen,int keepto) { if(lst) { - if(cnt == sz) return; // no change + if(cnt == sz) { + if(keepix != keepto) { + int c = keeplen >= 0?keeplen:cnt; + FLEXT_ASSERT(c+keepto <= cnt); + FLEXT_ASSERT(c+keepix <= cnt); + CopyAtoms(c,lst+keepto,lst+keepix); + } + + return; // no change + } t_atom *l; if(sz) { l = new t_atom[sz]; - if(keepix >= 0) + if(keepix >= 0) { // keep contents - CopyAtoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),l+keepto,lst+keepix); + int c = keeplen >= 0?keeplen:(cnt > sz?sz:cnt); + FLEXT_ASSERT(c+keepto <= sz); + FLEXT_ASSERT(c+keepix <= cnt); + CopyAtoms(c,l+keepto,lst+keepix); + } } else l = NULL; - delete[] lst; + Free(); lst = l,cnt = sz; } else { @@ -122,11 +135,21 @@ flext::AtomListStaticBase::~AtomListStaticBase() { Free(); } void flext::AtomListStaticBase::Alloc(int sz,int keepix,int keeplen,int keepto) { - if(sz < precnt) { + if(sz <= precnt) { + // small enough for pre-allocated space + if(lst != predata && lst) { - if(keepix >= 0) + // currently allocated memory is larger than what we need + + if(keepix >= 0) { // keep contents - CopyAtoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),predata+keepto,lst+keepix); + int c = keeplen >= 0?keeplen:(cnt > sz?sz:cnt); + FLEXT_ASSERT(c+keepto <= precnt); + FLEXT_ASSERT(c+keepix <= cnt); + CopyAtoms(c,predata+keepto,lst+keepix); + } + + // free allocated memory AtomList::Free(); } lst = predata,cnt = sz; -- cgit v1.2.1