gc_cpp.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*************************************************************************
  2. Copyright (c) 1994 by Xerox Corporation. All rights reserved.
  3. THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  4. OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  5. Last modified on Sat Nov 19 19:31:14 PST 1994 by ellis
  6. on Sat Jun 8 15:10:00 PST 1994 by boehm
  7. Permission is hereby granted to copy this code for any purpose,
  8. provided the above notices are retained on all copies.
  9. This implementation module for gc_c++.h provides an implementation of
  10. the global operators "new" and "delete" that calls the Boehm
  11. allocator. All objects allocated by this implementation will be
  12. non-collectable but part of the root set of the collector.
  13. You should ensure (using implementation-dependent techniques) that the
  14. linker finds this module before the library that defines the default
  15. built-in "new" and "delete".
  16. Authors: John R. Ellis and Jesse Hull
  17. **************************************************************************/
  18. /* Boehm, December 20, 1994 7:26 pm PST */
  19. #include "gc_cpp.h"
  20. void* operator new( size_t size ) {
  21. return GC_MALLOC_UNCOLLECTABLE( size );}
  22. void operator delete( void* obj ) {
  23. GC_FREE( obj );}
  24. #ifdef GC_OPERATOR_NEW_ARRAY
  25. void* operator new[]( size_t size ) {
  26. return GC_MALLOC_UNCOLLECTABLE( size );}
  27. void operator delete[]( void* obj ) {
  28. GC_FREE( obj );}
  29. #endif /* GC_OPERATOR_NEW_ARRAY */
  30. #ifdef _MSC_VER
  31. // This new operator is used by VC++ in case of Debug builds !
  32. void* operator new( size_t size,
  33. int ,//nBlockUse,
  34. const char * szFileName,
  35. int nLine )
  36. {
  37. #ifndef GC_DEBUG
  38. return GC_malloc_uncollectable( size );
  39. #else
  40. return GC_debug_malloc_uncollectable(size, szFileName, nLine);
  41. #endif
  42. }
  43. #endif /* _MSC_VER */