- Timestamp:
- Oct 25, 2008, 1:05:51 PM (16 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 3fe8ed4d13cc002b2f0fb89d6eeacd9ee3f7a568
- Parents:
- b0e3efca092d580bdd55fac90beff461dacda552
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/newdelete.cc
rb0e3efc rad83e4 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: newdelete.cc,v 1. 2 1997-06-19 12:22:03 schmidtExp $ */2 /* $Id: newdelete.cc,v 1.3 2008-10-25 11:04:06 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 11 11 #include "memman.h" 12 12 #endif 13 14 // The C++ standard has ratified a change to the new operator. 15 // 16 // T *p = new T; 17 // 18 // Previously, if the call to new above failed, a null pointer would've been returned. 19 // Under the ISO C++ Standard, an exception of type std::bad_alloc is thrown. 20 // It is possible to suppress this behaviour in favour of the old style 21 // by using the nothrow version. 22 // 23 // T *p = new (std::nothrow) T; 24 // 25 // So we have to overload this new also, just to be sure. 26 // 27 // A further interesting question is, if you don't have enough resources 28 // to allocate a request for memory, 29 // do you expect to have enough to be able to deal with it? 30 // Most operating systems will have slowed to be unusable 31 // long before the exception gets thrown. 13 32 14 33 #ifdef USE_OLD_MEMMAN … … 32 51 { 33 52 freeBlock( block, 0 ); 53 } 54 55 void * operator new(size_t size, const std::nothrow_t &) throw() 56 { 57 return getBlock( size ); 58 } 59 void * operator new[](size_t size, const std::nothrow_t &) throw() 60 { 61 return getBlock( size ); 34 62 } 35 63 … … 56 84 } 57 85 86 void * operator new(size_t size, const std::nothrow_t &) throw() 87 { 88 return mmAlloc( size ); 89 } 90 void * operator new[](size_t size, const std::nothrow_t &) throw() 91 { 92 return mmAlloc( size ); 93 } 94 58 95 #endif /* USE_OLD_MEMMAN */
Note: See TracChangeset
for help on using the changeset viewer.