Changeset ad83e4 in git for factory


Ignore:
Timestamp:
Oct 25, 2008, 1:05:51 PM (16 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3fe8ed4d13cc002b2f0fb89d6eeacd9ee3f7a568
Parents:
b0e3efca092d580bdd55fac90beff461dacda552
Message:
*hannes: new-nothrow


git-svn-id: file:///usr/local/Singular/svn/trunk@11159 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/newdelete.cc

    rb0e3efc rad83e4  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: newdelete.cc,v 1.2 1997-06-19 12:22:03 schmidt Exp $ */
     2/* $Id: newdelete.cc,v 1.3 2008-10-25 11:04:06 Singular Exp $ */
    33
    44#include <config.h>
     
    1111#include "memman.h"
    1212#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.
    1332
    1433#ifdef USE_OLD_MEMMAN
     
    3251{
    3352    freeBlock( block, 0 );
     53}
     54
     55void * operator new(size_t size, const std::nothrow_t &) throw()
     56{
     57    return getBlock( size );
     58}
     59void * operator new[](size_t size, const std::nothrow_t &) throw()
     60{
     61    return getBlock( size );
    3462}
    3563
     
    5684}
    5785
     86void * operator new(size_t size, const std::nothrow_t &) throw()
     87{
     88    return mmAlloc( size );
     89}
     90void * operator new[](size_t size, const std::nothrow_t &) throw()
     91{
     92    return mmAlloc( size );
     93}
     94
    5895#endif /* USE_OLD_MEMMAN */
Note: See TracChangeset for help on using the changeset viewer.