00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022
00023 #ifndef ALPHA_LINUX_CXX
00024 # include <cstdlib>
00025 # include <cstdio>
00026 #endif
00027 #include <new>
00028 #if 0
00029
00030 #include <pthread_alloc>
00031 #else
00032 #ifndef ALPHA_LINUX_CXX
00033 # include <cstring>
00034 #endif
00035 #endif
00036
00037 unsigned long exult_mem = 0L;
00038
00039 #ifdef WANT_ALTERNATE_ALLOCATOR
00040 #ifdef POISON_ALLOCATED_BLOCKS
00041 #undef INITIALISE_ALLOCATED_BLOCKS
00042 #define INITIALISE_ALLOCATED_BLOCKS 0xf1
00043 #endif
00044
00045 void *operator new (size_t) throw (std::bad_alloc);
00046 void *operator new[] (size_t) throw (std::bad_alloc);
00047
00048 void *operator new(size_t n) throw (std::bad_alloc)
00049 {
00050 void *r;
00051 r=malloc(n);
00052 if(!r)
00053 throw std::bad_alloc();
00054 #ifdef INITIALISE_ALLOCATED_BLOCKS
00055 memset(r,INITIALISE_ALLOCATED_BLOCKS,n);
00056 #endif
00057 exult_mem += n;
00058 return r;
00059 }
00060
00061 void *operator new[](size_t n) throw (std::bad_alloc)
00062 {
00063 void *r=malloc(n);
00064 if(!r)
00065 throw std::bad_alloc();
00066 #ifdef INITIALISE_ALLOCATED_BLOCKS
00067 memset(r,INITIALISE_ALLOCATED_BLOCKS,n);
00068 #endif
00069 exult_mem += n;
00070 return r;
00071 }
00072
00073 void operator delete(void *p) throw()
00074 {
00075 if(p)
00076 free(p);
00077
00078
00079 }
00080 void operator delete[](void *p) throw()
00081 {
00082 if(p)
00083 free(p);
00084 }
00085
00086 #endif