void *MemRealloc( void *ptr, size_t size ) /****************************************/ { MemPtr *mptr; if( ptr ) { mptr = ptr; mptr--; if( mptr == memPtr ) { memPtr = mptr->next; } if( mptr->prev ) { mptr->prev->next = mptr->next; } if( mptr->next ) { mptr->next->prev = mptr->prev; } ptr = mptr; } #ifdef TRMEM mptr = _trmem_realloc( ptr, size + sizeof( MemPtr ), _trmem_guess_who(), TRMemHandle ); #else mptr = realloc( ptr, size + sizeof( MemPtr ) ); #endif if( mptr == NULL ) FatalError( ERR_NO_MEMORY ); mptr->next = memPtr; mptr->prev = NULL; if( memPtr ) { memPtr->prev = mptr; } memPtr = mptr; return( mptr + 1 ); }
pointer CGAlloc( size_t size ) /****************************/ { pointer chunk; _MemLow; for( ;; ) { #if _MEMORY_TRACKING & _FULL_TRACKING chunk = _trmem_alloc( size, _trmem_guess_who(), Handle ); #else chunk = _SysAlloc( size ); #endif if( chunk != NULL ) { #if _MEMORY_TRACKING & _CHUNK_TRACKING ++Chunks; #endif _AlignmentCheck( chunk, 8 ); return( chunk ); } if( !_MemCheck( size ) ) { break; } } if( ( MemOut == MO_FATAL ) || ( InOptimizer != 0 ) ) { FatalError( "Out of memory" ); } else if( MemOut == MO_SUICIDE ) { Suicide(); } return( NULL ); }
void MFree( void *p ) { #ifdef TRMEM _trmem_free( p, _trmem_guess_who(), TRMemHandle ); #else free( p ); #endif }
void *operator new( size_t size ) /*******************************/ { void *p; #ifdef TRACKER _trmem_who caller; caller = _trmem_guess_who(); #endif #ifdef TRACKER p = _trmem_alloc( size, _trmem_guess_who(), TrHdl ); #else p = malloc( size ); #endif return p; }
void *WRAPI WRMemRealloc( void *ptr, size_t size ) { #ifdef TRMEM return( _trmem_realloc( ptr, size, _trmem_guess_who(), TRMemHandle ) ); #else return( realloc( ptr, size ) ); #endif }
void WRAPI WRMemFree( void *ptr ) { #ifdef TRMEM _trmem_free( ptr, _trmem_guess_who(), TRMemHandle ); #else free( ptr ); #endif }
void *WRAPI WRMemAlloc( size_t size ) { #ifdef TRMEM return( _trmem_alloc( size, _trmem_guess_who(), TRMemHandle ) ); #else return( malloc( size ) ); #endif }
extern void * TRMemAlloc( size_t size ) /*************************************/ { #ifdef TRMEM return( _trmem_alloc( size, _trmem_guess_who(), TRMemHandle ) ); #else return( malloc( size ) ); #endif }
extern void TRMemFree( void * ptr ) /*********************************/ { #ifdef TRMEM _trmem_free( ptr, _trmem_guess_who(), TRMemHandle ); #else free( ptr ); #endif }
void *LAlloc( size_t size ) /**************************/ { void (*ra)( void ); ra = _trmem_guess_who(); return( DoLAlloc( size, ra ) ); }
int RcMemValidate( void * ptr ) /*****************************/ { if (RcMemHandle != NULL) { return( _trmem_validate( ptr, _trmem_guess_who(), RcMemHandle ) ); } else { return( false ); } }
int WRAPI WRMemValidate( void *ptr ) { #ifdef TRMEM return( _trmem_validate( ptr, _trmem_guess_who(), TRMemHandle ) ); #else _wtouch( ptr ); return( TRUE ); #endif }
extern char * TRMemStrdup( const char * str ) /*******************************************/ { #ifdef TRMEM return( _trmem_strdup( str, _trmem_guess_who(), TRMemHandle ) ); #else return( strdup( str ) ); #endif }
void RcMemFree( void * ptr ) /**************************/ { #ifdef RC_USE_TRMEM _trmem_free( ptr, _trmem_guess_who(), RcMemHandle ); #else RCMemLayer1Free( ptr ); #endif }
extern void * TRMemRealloc( void * ptr, size_t size ) /***************************************************/ { #ifdef TRMEM return( _trmem_realloc( ptr, size, _trmem_guess_who(), TRMemHandle ) ); #else return( realloc( ptr, size ) ); #endif }
void MemFree( void *ptr ) { if( ptr != NULL ) { #ifdef TRMEM _trmem_free( ptr, _trmem_guess_who(), memHandle ); #else free( ptr ); #endif } }
int RcMemChkRange( void * start, size_t len ) /*******************************************/ { if (RcMemHandle != NULL) { return( _trmem_chk_range( start, len, _trmem_guess_who(), RcMemHandle ) ); } else { return( false ); } }
int WRAPI WRMemChkRange( void *start, size_t len ) { #ifdef TRMEM return( _trmem_chk_range( start, len, _trmem_guess_who(), TRMemHandle ) ); #else _wtouch( start ); _wtouch( len ); return( TRUE ); #endif }
void * WBRAlloc( size_t size ) /****************************/ // note: code directly cloned from above since we need to be able to trace // calling functions when the memory tracker is in. { void *p; #ifdef TRACKER _trmem_who caller; caller = _trmem_guess_who(); #endif #ifdef TRACKER p = _trmem_alloc( size, _trmem_guess_who(), TrHdl ); #else p = malloc( size ); #endif return p; }
void operator delete( void *p ) /*****************************/ { if( p == NULL ) return; #ifdef TRACKER _trmem_free( p, _trmem_guess_who(), TrHdl ); #else free( p ); #endif }
void *operator new( size_t size ) /*******************************/ { void *p; #ifdef TRACKER _trmem_who caller; caller = _trmem_guess_who(); #endif // for(;;) { #ifdef TRACKER p = _trmem_alloc( size, _trmem_guess_who(), TrHdl ); #else p = malloc( size ); #endif // if( p != NULL || !DRSwap() ) break; //only for browser // } return p; }
void MemFreeGlobal( void *ptr ) /*****************************/ { if( ptr == NULL ) return; #ifdef TRMEM _trmem_free( ptr, _trmem_guess_who(), TRMemHandle ); #else free( ptr ); #endif }
void *MemReallocGlobal( void *ptr, size_t size ) /**********************************************/ { #ifdef TRMEM ptr = _trmem_realloc( ptr, size, _trmem_guess_who(), TRMemHandle ); #else ptr = realloc( ptr, size ); #endif if( ptr == NULL && size != 0 ) FatalError( ERR_NO_MEMORY ); return( ptr ); }
void *MemRealloc( void *ptr, size_t size ) { void *p; #ifdef TRMEM p = _trmem_realloc( ptr, size, _trmem_guess_who(), TRMemHandle ); #else p = realloc( ptr, size ); #endif return( p ); }
void CGFree( pointer chunk ) /*****************************/ { #if _MEMORY_TRACKING & _CHUNK_TRACKING --Chunks; #endif #if _MEMORY_TRACKING & _FULL_TRACKING _trmem_free( chunk, _trmem_guess_who(), Handle ); #else _SysFree( chunk ); #endif }
void uifree( void *ptr ) { #ifdef TRMEM #ifndef __WATCOMC__ _trmem_free( ptr, (WHO_PTR)3, trmemHandle ); #else _trmem_free( ptr, _trmem_guess_who(), trmemHandle ); #endif #else free( ptr ); #endif }
void *MemReAllocUnsafe( void *ptr, size_t size ) { #ifdef TRMEM #ifndef __WATCOMC__ return( doMemReAllocUnsafe( ptr, size, (WHO_PTR)5 ) ); #else return( doMemReAllocUnsafe( ptr, size, _trmem_guess_who() ) ); #endif #else return( doMemReAllocUnsafe( ptr, size, (WHO_PTR)0 ) ); #endif }
void LFree( void *p ) /**************************/ { if( p == NULL ) return; #ifdef TRMEM _trmem_free( p, _trmem_guess_who(), TrHdl ); #else free( p ); #endif #ifdef _INT_DEBUG --Chunks; #endif }
/* * MemAllocUnsafe - allocate some memory, return null if it fails */ void *MemAllocUnsafe( size_t size ) { #ifdef TRMEM #ifndef __WATCOMC__ return( doMemAllocUnsafe( size, (WHO_PTR)2 ) ); #else return( doMemAllocUnsafe( size, _trmem_guess_who() ) ); #endif #else return( doMemAllocUnsafe( size, (WHO_PTR)0 ) ); #endif } /* MemAllocUnsafe */
/* * MemFreePtr - free up memory */ void MemFreePtr( void **ptr ) { #ifdef TRMEM #ifndef __WATCOMC__ _trmem_free( *ptr, (WHO_PTR)4, trmemHandle ); #else _trmem_free( *ptr, _trmem_guess_who(), trmemHandle ); #endif #else free( *ptr ); #endif *ptr = NULL; } /* MemFreePtr */