Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnNew.h File Reference

#include <new>
#include <pthread.h>
#include "PsName.h"

Include dependency graph for PsnNew.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Compounds

class  HeapStackTop
 personnal version of the HeapStackTop class by Nathan C.Myers described in the july and august 1993 articles of C++ report entitled MemoryManagement in C++ More...


Functions

void * operator new (size_t) throw (bad_alloc)
void * operator new[] (size_t) throw (bad_alloc)
void operator delete (void *) throw ()
void operator delete[] (void *) throw ()
void * operator new (size_t, const nothrow_t &) throw ()
void * operator new[] (size_t, const nothrow_t &) throw ()
void operator delete (void *, const nothrow_t &) throw ()
void operator delete[] (void *, const nothrow_t &) throw ()


Function Documentation

void operator delete void *   ,
const nothrow_t &   
throw ()
 

Definition at line 204 of file PsnNew.cxx.

Referenced by PsAllocatorT< T >::deallocate(), and operator delete[]().

00205 {
00206    operator delete(ptr) ;
00207    //operator delete(ptr);
00208 }

void operator delete void *    throw ()
 

Definition at line 176 of file PsnNew.cxx.

00176                                           {
00177 #ifdef _DEBUGMEMORYMANAGEMENT
00178    cerr<<"Utilisation de delete "<<ptr<<endl;
00179 #endif
00180    if ( ptr != 0 ) 
00181       {
00182          PsnMemoryManager * currentMemoryManager = (PsnMemoryManager *) (pthread_getspecific( HeapStackTop::globalMemoryManagerKey ) );
00183 
00184          if ( currentMemoryManager != NULL )
00185             {
00186                // heuristic: the correct memory manager to use is probably the current memory manager
00187                // this heuristic enables to avoid global search (and look) for the correct memory manager in the good cases
00188                currentMemoryManager->freeSizeRemembered( ptr );
00189             }
00190       }
00191 #ifdef _DEBUGMEMORYMANAGEMENT
00192    cerr<<"Utilisation de delete fin"<<endl;
00193 #endif
00194 }

void operator delete[] void *   ,
const nothrow_t &   
throw ()
 

Definition at line 210 of file PsnNew.cxx.

References operator delete().

00211 {
00212    operator delete(ptr);
00213    //operator delete(ptr);
00214 }

void operator delete[] void *    throw ()
 

Definition at line 196 of file PsnNew.cxx.

00196                                             {
00197 #ifdef _DEBUGMEMORYMANAGEMENT
00198    cerr<<"operator delete[] (void * ptr) throw()"<<endl;
00199 #endif
00200    operator delete ( ptr ) ;
00201    //   operator delete(ptr);
00202 }

void* operator new size_t   ,
const nothrow_t &   
throw ()
 

Definition at line 167 of file PsnNew.cxx.

Referenced by PsAllocatorT< T >::allocate(), HeapStackTop::operator new(), and operator new[]().

00168 {
00169    return operator new(size);
00170 }

void* operator new size_t    throw (bad_alloc)
 

Definition at line 119 of file PsnNew.cxx.

00120 {
00121    /* because new could be used during static allocations, and that order of static initialisation 
00122     * cannot be controlled, the first time new is called it's possible that HeapStackTop::globalMemoryManagerKey
00123     * has not yet been initialised. Therefore, a correct initialisation of 
00124     * HeapStackTop::globalMemoryManagerKey has to be generated on the first call to the redefined new*/
00125 
00126    static pthread_key_t bidon = HeapStackTop::initialiseGlobalMemoryManagerKey () ;
00127 
00128 #ifdef _DEBUGMEMORYMANAGEMENT
00129    assert ( bidon == HeapStackTop::globalMemoryManagerKey ) ;
00130 #endif
00131 
00132    void * resul;
00133 #ifdef _DEBUGMEMORYMANAGEMENT
00134    cerr<<"Utilisation de new "<<endl;
00135 #endif
00136    void * currentMemoryManager = (PsnMemoryManager *) pthread_getspecific( HeapStackTop::globalMemoryManagerKey ) ;
00137 
00138 #ifdef _DEBUGMEMORYMANAGEMENT
00139    assert ( currentMemoryManager != NULL ) ;
00140 #endif
00141 
00142    resul = ( (PsnMemoryManager *)currentMemoryManager)->allocateSizeRemembered(size);
00143       
00144 #ifdef _DEBUGMEMORYMANAGEMENT
00145    cerr<<"Utilisation de new fin "<<resul<<endl;
00146 #endif
00147    return resul;
00148 }

void* operator new[] size_t   ,
const nothrow_t &   
throw ()
 

Definition at line 172 of file PsnNew.cxx.

References operator new().

00172                                                              {
00173    return operator new(size);
00174 }

void* operator new[] size_t    throw (bad_alloc)
 

Definition at line 152 of file PsnNew.cxx.

00153 {
00154    void * resul = operator new(size) ;
00155    if (resul != NULL) 
00156       {
00157          return resul ;
00158       }
00159    else 
00160       {
00161          throw bad_alloc() ;
00162       }
00163 }


logo OpenMask

Documentation generated on Mon Nov 25 15:25:29 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001