Back to index

lightning-sunbird  0.9+nobinonly
gc_cpp.cc
Go to the documentation of this file.
00001 /*************************************************************************
00002 Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
00003  
00004 THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
00005 OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
00006  
00007     Last modified on Sat Nov 19 19:31:14 PST 1994 by ellis
00008                   on Sat Jun  8 15:10:00 PST 1994 by boehm
00009 
00010 Permission is hereby granted to copy this code for any purpose,
00011 provided the above notices are retained on all copies.
00012 
00013 This implementation module for gc_c++.h provides an implementation of
00014 the global operators "new" and "delete" that calls the Boehm
00015 allocator.  All objects allocated by this implementation will be
00016 non-collectable but part of the root set of the collector.
00017 
00018 You should ensure (using implementation-dependent techniques) that the
00019 linker finds this module before the library that defines the default
00020 built-in "new" and "delete".
00021 
00022 Authors: John R. Ellis and Jesse Hull
00023 
00024 **************************************************************************/
00025 /* Boehm, December 20, 1994 7:26 pm PST */
00026 
00027 #include "gc_cpp.h"
00028 
00029 void* operator new( size_t size )
00030 {
00031     return GC_MALLOC( size );
00032 }
00033   
00034 void operator delete( void* obj )
00035 {
00036     GC_FREE( obj );
00037 }
00038   
00039 #ifdef _MSC_VER
00040 // This new operator is used by VC++ in case of Debug builds !
00041 void* operator new( size_t size,
00042                     int ,//nBlockUse,
00043                     const char * szFileName,
00044                     int nLine
00045                     ) {
00046 # ifndef GC_DEBUG
00047     return GC_malloc_uncollectable( size );
00048 # else
00049     return GC_debug_malloc_uncollectable(size, szFileName, nLine);
00050 # endif
00051 }
00052 #endif
00053 
00054 #ifdef OPERATOR_NEW_ARRAY
00055 
00056 void* operator new[]( size_t size )
00057 {
00058     return GC_MALLOC( size );
00059 }
00060   
00061 void operator delete[]( void* obj )
00062 {
00063     GC_FREE( obj );
00064 }
00065 
00066 #endif /* OPERATOR_NEW_ARRAY */
00067 
00068