X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=hs-boehmgc.git;a=blobdiff_plain;f=gc-7.2%2Fgc_cpp.cc;fp=gc-7.2%2Fgc_cpp.cc;h=583e6cd93c605e21fd4f464b46b304f90aa12074;hp=0000000000000000000000000000000000000000;hb=324587ba93dc77f37406d41fd2a20d0e0d94fb1d;hpb=2a4ea609491b225a1ceb06da70396e93916f137a diff --git a/gc-7.2/gc_cpp.cc b/gc-7.2/gc_cpp.cc new file mode 100644 index 0000000..583e6cd --- /dev/null +++ b/gc-7.2/gc_cpp.cc @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Last modified on Sat Nov 19 19:31:14 PST 1994 by ellis + * + * Permission is hereby granted to copy this code for any purpose, + * provided the above notices are retained on all copies. + */ + +/************************************************************************* +This implementation module for gc_c++.h provides an implementation of +the global operators "new" and "delete" that calls the Boehm +allocator. All objects allocated by this implementation will be +non-collectable but part of the root set of the collector. + +You should ensure (using implementation-dependent techniques) that the +linker finds this module before the library that defines the default +built-in "new" and "delete". + +Authors: John R. Ellis and Jesse Hull + +**************************************************************************/ + +# ifdef HAVE_CONFIG_H +# include "private/config.h" +# endif + +# ifndef GC_BUILD +# define GC_BUILD +# endif + +#include "gc_cpp.h" + +void* operator new( size_t size ) { + return GC_MALLOC_UNCOLLECTABLE( size );} + +#if !defined(__CYGWIN__) + void operator delete( void* obj ) { + GC_FREE( obj ); + } +#endif /* !__CYGWIN__ */ + +#ifdef GC_OPERATOR_NEW_ARRAY + +void* operator new[]( size_t size ) { + return GC_MALLOC_UNCOLLECTABLE( size );} + +void operator delete[]( void* obj ) { + GC_FREE( obj );} + +#endif /* GC_OPERATOR_NEW_ARRAY */ + +#ifdef _MSC_VER + +// This new operator is used by VC++ in case of Debug builds ! +void* operator new( size_t size, + int ,//nBlockUse, + const char * szFileName, + int nLine ) +{ +#ifndef GC_DEBUG + return GC_malloc_uncollectable( size ); +#else + return GC_debug_malloc_uncollectable(size, szFileName, nLine); +#endif +} + +#if _MSC_VER > 1020 +// This new operator is used by VC++ 7.0 and later in Debug builds. +void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine) +{ + return operator new(size, nBlockUse, szFileName, nLine); +} +#endif + +#endif /* _MSC_VER */