usermode/library/malloc-hoard-old/src/mallocwrap.cpp

00001 
00002 //
00003 // The Hoard Multiprocessor Memory Allocator
00004 // www.hoard.org
00005 //
00006 // Author: Emery Berger, http://www.cs.utexas.edu/users/emery
00007 //
00008 // Copyright (c) 1998-2001, The University of Texas at Austin.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Library General Public License as
00012 // published by the Free Software Foundation, http://www.fsf.org.
00013 //
00014 // This library is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Library General Public License for more details.
00018 //
00020 
00021 /*
00022 
00023   Wrappers that re-route everything, to ordinary ANSI C calls (except for size).
00024 
00025   by Emery Berger
00026 
00027 */
00028 
00029 //TODO: 
00030 #error "What C++ keywords to wrap for persistent allocator?"
00031 
00032 #include <stdlib.h>
00033 #if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x420
00034 #include <new>
00035 #endif
00036 
00037 #if 1
00038 extern "C" void * malloc (size_t);
00039 extern "C" void free (void *);
00040 extern "C" void * calloc (size_t, size_t);
00041 extern "C" void * realloc (void *, size_t);
00042 extern "C" size_t malloc_usable_size (void *);
00043 #endif
00044 
00045 
00046 void * operator new (size_t size)
00047 {
00048   return malloc (size);
00049 }
00050 
00051 void operator delete (void * ptr)
00052 {
00053   free (ptr);
00054 }
00055 
00056 #if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x420
00057 
00058 void * operator new (size_t size, const std::nothrow_t&) throw() {
00059   return malloc (size);
00060 } 
00061 
00062 void * operator new[] (size_t size) throw(std::bad_alloc)
00063 {
00064   return malloc (size);
00065 }
00066 
00067 void * operator new[] (size_t size, const std::nothrow_t&) throw() {
00068   return malloc (size);
00069 } 
00070 
00071 void operator delete[] (void * ptr) throw()
00072 {
00073   free (ptr);
00074 }
00075 #endif

Generated on Sat Apr 23 11:43:35 2011 for Mnemosyne by  doxygen 1.4.7