示例#1
0
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 );
}
示例#2
0
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 );
}
示例#3
0
void MFree( void *p )
{
#ifdef TRMEM
    _trmem_free( p, _trmem_guess_who(), TRMemHandle );
#else
    free( p );
#endif
}
示例#4
0
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;
}
示例#5
0
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
}
示例#6
0
void WRAPI WRMemFree( void *ptr )
{
#ifdef TRMEM
    _trmem_free( ptr, _trmem_guess_who(), TRMemHandle );
#else
    free( ptr );
#endif
}
示例#7
0
void *WRAPI WRMemAlloc( size_t size )
{
#ifdef TRMEM
    return( _trmem_alloc( size, _trmem_guess_who(), TRMemHandle ) );
#else
    return( malloc( size ) );
#endif
}
示例#8
0
extern void * TRMemAlloc( size_t size )
/*************************************/
{
#ifdef TRMEM
    return( _trmem_alloc( size, _trmem_guess_who(), TRMemHandle ) );
#else
    return( malloc( size ) );
#endif
}
示例#9
0
extern void TRMemFree( void * ptr )
/*********************************/
{
#ifdef TRMEM
    _trmem_free( ptr, _trmem_guess_who(), TRMemHandle );
#else
    free( ptr );
#endif
}
示例#10
0
 void *LAlloc( size_t size )
/**************************/
{
    void        (*ra)( void );

    ra = _trmem_guess_who();

    return( DoLAlloc( size, ra ) );
}
示例#11
0
int RcMemValidate( void * ptr )
/*****************************/
{
    if (RcMemHandle != NULL) {
        return( _trmem_validate( ptr, _trmem_guess_who(), RcMemHandle ) );
    } else {
        return( false );
    }
}
示例#12
0
int WRAPI WRMemValidate( void *ptr )
{
#ifdef TRMEM
    return( _trmem_validate( ptr, _trmem_guess_who(), TRMemHandle ) );
#else
    _wtouch( ptr );
    return( TRUE );
#endif
}
示例#13
0
extern char * TRMemStrdup( const char * str )
/*******************************************/
{
#ifdef TRMEM
    return( _trmem_strdup( str, _trmem_guess_who(), TRMemHandle ) );
#else
    return( strdup( str ) );
#endif
}
示例#14
0
void RcMemFree( void * ptr )
/**************************/
{
#ifdef RC_USE_TRMEM
    _trmem_free( ptr, _trmem_guess_who(), RcMemHandle );
#else
    RCMemLayer1Free( ptr );
#endif
}
示例#15
0
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
}
示例#16
0
void MemFree( void *ptr )
{
    if( ptr != NULL ) {
#ifdef TRMEM
        _trmem_free( ptr, _trmem_guess_who(), memHandle );
#else
        free( ptr );
#endif
    }
}
示例#17
0
int RcMemChkRange( void * start, size_t len )
/*******************************************/
{
    if (RcMemHandle != NULL) {
        return( _trmem_chk_range( start, len,
                        _trmem_guess_who(), RcMemHandle ) );
    } else {
        return( false );
    }
}
示例#18
0
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
}
示例#19
0
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;
}
示例#20
0
void operator delete( void *p )
/*****************************/
{
    if( p == NULL ) return;
#ifdef TRACKER
    _trmem_free( p, _trmem_guess_who(), TrHdl );
#else
    free( p );
#endif
}
示例#21
0
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;
}
示例#22
0
void MemFreeGlobal( void *ptr )
/*****************************/
{
    if( ptr == NULL )
        return;
#ifdef TRMEM
    _trmem_free( ptr, _trmem_guess_who(), TRMemHandle );
#else
    free( ptr );
#endif
}
示例#23
0
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 );
}
示例#24
0
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 );
}
示例#25
0
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
}
示例#26
0
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
}
示例#27
0
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
}
示例#28
0
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
}
示例#29
0
/*
 * 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 */
示例#30
0
/*
 * 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 */