From d399ea9333e69c2506ba09754a8c1b8d292e9085 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 10 Dec 2005 21:34:08 +0000 Subject: some minor changes after valgrind run fix uninitialized pointer With FLEXT_USECMEM normal C library memory allocation will be used, otherwise global operators will be overridden to use memory allocation by the real-time system (getbytes). more pthreads V2 fixes Deprecated FLEXT_NOGLOBALNEW in favor of FLEXT_USECMEM. svn path=/trunk/; revision=4184 --- externals/grill/flext/source/flout.cpp | 1 + externals/grill/flext/source/flsupport.cpp | 4 ++++ externals/grill/flext/source/flsupport.h | 33 +++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) (limited to 'externals/grill/flext/source') diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index d4066568..c95bf8fa 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -104,6 +104,7 @@ bool flext_base::InitInlets() // this is on a per-class basis... we cannot really use it here // if(xi.desc && *xi.desc) class_settip(thisClass(),gensym(xi.desc)); #endif + inlets[0] = NULL; } for(int ix = 1; ix < incnt; ++ix,++cnt) { diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp index a05f2b04..3443eb46 100644 --- a/externals/grill/flext/source/flsupport.cpp +++ b/externals/grill/flext/source/flsupport.cpp @@ -104,6 +104,8 @@ void flext::Setup() #define LARGEALLOC 32000 +#ifndef FLEXT_USECMEM + #ifdef FLEXT_DEBUGMEM static const size_t memtest = 0x12345678L; #endif @@ -192,6 +194,8 @@ bool flext_root::MemCheck(void *blk) } #endif +#endif + void *flext_root::NewAligned(size_t bytes,int bitalign) { const size_t ovh = sizeof(size_t)+sizeof(char *); diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 87e198f8..eb358647 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -46,6 +46,20 @@ public: @{ */ +#ifdef FLEXT_NOGLOBALNEW +#error FLEXT_NOGLOBALNEW is deprecated, define FLEXT_USECMEM instead +#define FLEXT_USECMEM +#endif + +#ifdef FLEXT_USECMEM + inline void *operator new(size_t bytes) { return ::operator new(bytes); } + inline void operator delete(void *blk) { ::operator delete(blk); } + + inline void *operator new[](size_t bytes) { return ::operator new[](bytes); } + inline void operator delete[](void *blk) { ::operator delete[](blk); } + + static bool MemCheck(void *) { return true; } +#else /*! Overloaded new memory allocation method \note this uses a fast allocation method of the real-time system \warning Max/MSP (or MacOS) allows only 32K in overdrive mode! @@ -54,9 +68,9 @@ public: //! Overloaded delete method void operator delete(void *blk); -#ifndef __BORLANDC__ - inline void *operator new(size_t,void *p) { return p; } - inline void operator delete(void *,void *) {} +#ifndef __MRC__ // doesn't allow new[] overloading?! + inline void *operator new[](size_t bytes) { return operator new(bytes); } + inline void operator delete[](void *blk) { operator delete(blk); } #endif #ifdef FLEXT_DEBUGMEM @@ -65,11 +79,12 @@ public: static bool MemCheck(void *) { return true; } #endif -#ifndef __MRC__ // doesn't allow new[] overloading?! - inline void *operator new[](size_t bytes) { return operator new(bytes); } - inline void operator delete[](void *blk) { operator delete(blk); } +#endif // USECMEM #ifndef __BORLANDC__ + inline void *operator new(size_t,void *p) { return p; } + inline void operator delete(void *,void *) {} +#ifndef __MRC__ inline void *operator new[](size_t,void *p) { return p; } inline void operator delete[](void *,void *) {} #endif @@ -89,7 +104,7 @@ public: //! @} FLEXT_S_MEMORY }; -#ifndef FLEXT_NOGLOBALNEW +#ifndef FLEXT_USECMEM /************************************************************************/ // MFC doesn't like global overloading of allocators // anyway, who likes MFC @@ -110,7 +125,7 @@ inline void *operator new[](size_t bytes) NEWTHROW { return flext_root::operator inline void operator delete[](void *blk) DELTHROW { flext_root::operator delete[](blk); } #endif -#endif // FLEXT_NOGLOBALNEW +#endif // FLEXT_USECMEM /************************************************************************/ @@ -792,8 +807,6 @@ public: static bool IsThread(thrid_t t,thrid_t ref = GetThreadId()) { #if FLEXT_THREADS == FLEXT_THR_POSIX return pthread_equal(ref,t) != 0; -#elif FLEXT_THREADS == FLEXT_THR_WIN32 - return ref == t; #else return ref == t; #endif -- cgit v1.2.1