[PD-cvs] externals/grill/flext/source flbuf.cpp,1.15,1.16 fldsp.cpp,1.19,1.20 flsupport.cpp,1.24,1.25 flsupport.h,1.55,1.56

xovo at users.sourceforge.net xovo at users.sourceforge.net
Sat Nov 29 04:32:50 CET 2003


Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1:/tmp/cvs-serv27499/source

Modified Files:
	flbuf.cpp fldsp.cpp flsupport.cpp flsupport.h 
Log Message:
 ""

Index: flbuf.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbuf.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** flbuf.cpp	12 Aug 2003 02:32:51 -0000	1.15
--- flbuf.cpp	29 Nov 2003 03:32:48 -0000	1.16
***************
*** 195,199 ****
  	if(keep) {
  		// copy buffer data to tmp storage
! 		tmp = new t_sample[sz];
          if(tmp)
  			CopySamples(tmp,data,sz);
--- 195,199 ----
  	if(keep) {
  		// copy buffer data to tmp storage
!         tmp = (t_sample *)NewAligned(sz*sizeof(t_sample));
          if(tmp)
  			CopySamples(tmp,data,sz);
***************
*** 216,220 ****
  		// copy data back
  		CopySamples(data,tmp,sz);
! 		delete[] tmp;
          if(zero && sz < fr) ZeroSamples(data+sz,fr-sz);
  	}
--- 216,220 ----
  		// copy data back
  		CopySamples(data,tmp,sz);
! 		FreeAligned(tmp);
          if(zero && sz < fr) ZeroSamples(data+sz,fr-sz);
  	}

Index: fldsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/fldsp.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** fldsp.cpp	14 Aug 2003 02:32:51 -0000	1.19
--- fldsp.cpp	29 Nov 2003 03:32:48 -0000	1.20
***************
*** 17,22 ****
  #include <string.h>
  
- 
- 
  // === flext_dsp ==============================================
  
--- 17,20 ----

Index: flsupport.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** flsupport.cpp	19 Nov 2003 03:32:54 -0000	1.24
--- flsupport.cpp	29 Nov 2003 03:32:48 -0000	1.25
***************
*** 89,106 ****
  /////////////////////////////////////////////////////////
  
  void *flext_root::operator new(size_t bytes)
  {
  	bytes += sizeof(size_t);
  
! #ifdef FLEXT_DEBUG
! 	if(bytes > 32000)
! 		post("flext - warning: excessive memory allocation of %i bytes",bytes);
! #endif
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
! 	char *blk = (char *)::fts_malloc(bytes);
  #else
! 	char *blk = (char *)::getbytes(bytes);
  #endif
  
  	*(size_t *)blk = bytes;
--- 89,112 ----
  /////////////////////////////////////////////////////////
  
+ #define LARGEALLOC 32000
+ 
  void *flext_root::operator new(size_t bytes)
  {
  	bytes += sizeof(size_t);
  
!     char *blk;
!     if(bytes >= LARGEALLOC) {
!         // use C library function for large memory blocks
!         blk = (char *)::operator new(bytes);
!     }
!     else {
! 	//! \todo We need system locking here for secondary threads!
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
!     	blk = (char *)::fts_malloc(bytes);
  #else
! 	    blk = (char *)::getbytes(bytes);
  #endif
+     }
  
  	*(size_t *)blk = bytes;
***************
*** 111,121 ****
  {
  	char *ori = (char *)blk-sizeof(size_t);
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
! 	fts_free(ori);
  #else
! 	size_t bytes = *(size_t *)ori;
! 	::freebytes(ori,bytes);
  #endif
  }
  
--- 117,135 ----
  {
  	char *ori = (char *)blk-sizeof(size_t);
+ 	size_t bytes = *(size_t *)ori;
+ 
+     if(bytes >= LARGEALLOC) {
+         // use C library function for large memory blocks
+         ::operator delete(ori);
+     }
+     else {
+ 	//! \todo We need system locking here for secondary threads!
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
!     	fts_free(ori);
  #else
! 	    ::freebytes(ori,bytes);
  #endif
+     }
  }
  
***************
*** 126,134 ****
  	bytes += ovh+alignovh;
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
! 	char *blk = (char *)::fts_malloc(bytes);
  #else
! 	char *blk = (char *)::getbytes(bytes);
  #endif
  
  	char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh);
--- 140,157 ----
  	bytes += ovh+alignovh;
  
+     char *blk;
+     if(bytes >= LARGEALLOC) {
+         // use C library function for large memory blocks
+         blk = (char *)::operator new(bytes);
+     }
+     else {
+ 	//! \todo We need system locking here for secondary threads!
+ 
  #if FLEXT_SYS == FLEXT_SYS_JMAX
!     	blk = (char *)::fts_malloc(bytes);
  #else
! 	    blk = (char *)::getbytes(bytes);
  #endif
+     }
  
  	char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh);
***************
*** 141,151 ****
  {
  	char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *));
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
! 	fts_free(ori);
  #else
! 	size_t bytes = *(size_t *)((char *)blk-sizeof(size_t));
! 	::freebytes(ori,bytes);
  #endif
  }
  
--- 164,182 ----
  {
  	char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *));
+ 	size_t bytes = *(size_t *)((char *)blk-sizeof(size_t));
+ 
+     if(bytes >= LARGEALLOC) {
+         // use C library function for large memory blocks
+         ::operator delete(ori);
+     }
+     else {
+ 	//! \todo We need system locking here for secondary threads!
  
  #if FLEXT_SYS == FLEXT_SYS_JMAX
!     	fts_free(ori);
  #else
! 	    ::freebytes(ori,bytes);
  #endif
+     }
  }
  

Index: flsupport.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** flsupport.h	13 Nov 2003 03:33:09 -0000	1.55
--- flsupport.h	29 Nov 2003 03:32:48 -0000	1.56
***************
*** 55,65 ****
  		#endif
  
- 		/*! Get a large memory block
- 			the normal C library function is used here
- 		*/
- 		static void *NewLarge(size_t bytes) { return ::operator new(bytes); }
- 		//! Free a large memory block
- 		static void FreeLarge(void *blk) { ::operator delete(blk); }
- 
  		//! Get an aligned memory block
  		static void *NewAligned(size_t bytes,int bitalign = 128);
--- 55,58 ----
***************
*** 70,77 ****
              return (reinterpret_cast<unsigned long>(ptr)&(bitalign-1)) == 0; 
          }
- 		
  	//!	@}  FLEXT_S_MEMORY  	
- 
  };
  
  
--- 63,77 ----
              return (reinterpret_cast<unsigned long>(ptr)&(bitalign-1)) == 0; 
          }
  	//!	@}  FLEXT_S_MEMORY  	
  };
+ 
+ // define global new/delete operators
+ inline void *operator new(size_t bytes) { return flext_root::operator new(bytes); }
+ inline void operator delete(void *blk) { flext_root::operator delete(blk); }
+ #ifndef __MRC__ // doesn't allow new[] overloading?!
+ inline void *operator new[](size_t bytes) { return flext_root::operator new[](bytes); }
+ inline void operator delete[](void *blk) { flext_root::operator delete[](blk); }
+ #endif
+ 
  
  






More information about the Pd-cvs mailing list