Back to index

plt-scheme  4.2.1
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     return GC_MALLOC_UNCOLLECTABLE( size );}
00031   
00032 void operator delete( void* obj ) {
00033     GC_FREE( obj );}
00034   
00035 #ifdef GC_OPERATOR_NEW_ARRAY
00036 
00037 void* operator new[]( size_t size ) {
00038     return GC_MALLOC_UNCOLLECTABLE( size );}
00039   
00040 void operator delete[]( void* obj ) {
00041     GC_FREE( obj );}
00042 
00043 #endif /* GC_OPERATOR_NEW_ARRAY */
00044 
00045 #ifdef _MSC_VER
00046 
00047 // This new operator is used by VC++ in case of Debug builds !
00048 void* operator new( size_t size,
00049                        int ,//nBlockUse,
00050                        const char * szFileName,
00051                        int nLine )
00052 {
00053 #ifndef GC_DEBUG
00054        return GC_malloc_uncollectable( size );
00055 #else
00056        return GC_debug_malloc_uncollectable(size, szFileName, nLine);
00057 #endif
00058 }
00059 
00060 #endif /* _MSC_VER */
00061