diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index ee4819cb2..b91afc1e9 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -169,10 +169,7 @@ cac::cac ( cacNotify & notifyIn, bool enablePreemptiveCallbackIn ) : tmp[0] = '\0'; } len = strlen ( tmp ) + 1; - this->pUserName = new ( std::nothrow ) char [ len ]; - if ( ! this->pUserName ) { - throw std::bad_alloc (); - } + this->pUserName = new char [ len ]; strncpy ( this->pUserName, tmp, len ); } @@ -673,12 +670,7 @@ cacChannel & cac::createChannel ( const char * pName, } epics_auto_ptr < cacChannel > pNetChan ( new nciu ( *this, limboIIU, chan, pName, pri ) ); - if ( pNetChan.get() ) { - return *pNetChan.release (); - } - else { - throw std::bad_alloc (); - } + return *pNetChan.release (); } } return *pIO; @@ -1038,17 +1030,12 @@ cac::writeNotifyRequest ( nciu &chan, unsigned type, // X aCC 361 epicsGuard < epicsMutex > guard ( this->mutex ); autoPtrRecycle < netWriteNotifyIO > pIO ( this->ioTable, chan.cacPrivateListOfIO::eventq, *this, netWriteNotifyIO::factory ( this->freeListWriteNotifyIO, chan, notifyIn ) ); - if ( pIO.get() ) { - this->ioTable.add ( *pIO ); - chan.cacPrivateListOfIO::eventq.add ( *pIO ); - this->flushIfRequired ( guard, *chan.getPIIU() ); - chan.getPIIU()->writeNotifyRequest ( - chan, *pIO, type, nElem, pValue ); - return pIO.release()->getId (); - } - else { - throw std::bad_alloc (); - } + this->ioTable.add ( *pIO ); + chan.cacPrivateListOfIO::eventq.add ( *pIO ); + this->flushIfRequired ( guard, *chan.getPIIU() ); + chan.getPIIU()->writeNotifyRequest ( + chan, *pIO, type, nElem, pValue ); + return pIO.release()->getId (); } cacChannel::ioid @@ -1059,16 +1046,11 @@ cac::readNotifyRequest ( nciu &chan, unsigned type, // X aCC 361 autoPtrRecycle < netReadNotifyIO > pIO ( this->ioTable, chan.cacPrivateListOfIO::eventq, *this, netReadNotifyIO::factory ( this->freeListReadNotifyIO, chan, notifyIn ) ); - if ( pIO.get() ) { - this->ioTable.add ( *pIO ); - chan.cacPrivateListOfIO::eventq.add ( *pIO ); - this->flushIfRequired ( guard, *chan.getPIIU() ); - chan.getPIIU()->readNotifyRequest ( chan, *pIO, type, nElem ); - return pIO.release()->getId (); - } - else { - throw std::bad_alloc (); - } + this->ioTable.add ( *pIO ); + chan.cacPrivateListOfIO::eventq.add ( *pIO ); + this->flushIfRequired ( guard, *chan.getPIIU() ); + chan.getPIIU()->readNotifyRequest ( chan, *pIO, type, nElem ); + return pIO.release()->getId (); } void cac::ioCancel ( nciu &chan, const cacChannel::ioid &id ) @@ -1363,20 +1345,15 @@ cac::subscriptionRequest ( nciu &chan, unsigned type, // X aCC 361 chan.cacPrivateListOfIO::eventq, *this, netSubscription::factory ( this->freeListSubscription, chan, type, nElem, mask, notifyIn ) ); - if ( pIO.get() ) { - this->ioTable.add ( *pIO ); - chan.cacPrivateListOfIO::eventq.add ( *pIO ); - if ( chan.connected () ) { - this->flushIfRequired ( guard, *chan.getPIIU() ); - chan.getPIIU()->subscriptionRequest ( chan, *pIO ); - } - cacChannel::ioid id = pIO->getId (); - pIO.release (); - return id; - } - else { - throw std::bad_alloc(); + this->ioTable.add ( *pIO ); + chan.cacPrivateListOfIO::eventq.add ( *pIO ); + if ( chan.connected () ) { + this->flushIfRequired ( guard, *chan.getPIIU() ); + chan.getPIIU()->subscriptionRequest ( chan, *pIO ); } + cacChannel::ioid id = pIO->getId (); + pIO.release (); + return id; } bool cac::noopAction ( epicsGuard < callbackMutex > &, tcpiiu &, diff --git a/src/ca/comBuf.h b/src/ca/comBuf.h index 60a78c5ee..b9a4b8f40 100644 --- a/src/ca/comBuf.h +++ b/src/ca/comBuf.h @@ -67,7 +67,7 @@ public: unsigned copyOutBytes ( void *pBuf, unsigned nBytes ); bool copyOutAllBytes ( void *pBuf, unsigned nBytes ); unsigned removeBytes ( unsigned nBytes ); - void * operator new ( size_t size, const std::nothrow_t & ); + void * operator new ( size_t size ); void operator delete ( void *pCadaver, size_t size ); bool flushToWire ( wireSendAdapter & ); unsigned fillFromWire ( wireRecvAdapter & ); @@ -116,7 +116,7 @@ inline void comBuf::clear () this->nextReadIndex = 0u; } -inline void * comBuf::operator new ( size_t size, const std::nothrow_t & ) +inline void * comBuf::operator new ( size_t size ) { return comBuf::pFreeList->allocate ( size ); } diff --git a/src/ca/comQueSend.h b/src/ca/comQueSend.h index 447b26092..147b8a836 100644 --- a/src/ca/comQueSend.h +++ b/src/ca/comQueSend.h @@ -79,10 +79,7 @@ private: nCopied = 0u; } while ( nElem > nCopied ) { - comBuf * pComBuf = new ( std::nothrow ) comBuf; - if ( ! pComBuf ) { - throw std::bad_alloc (); - } + comBuf * pComBuf = new comBuf; unsigned nNew = pComBuf->copyIn ( &pVal[nCopied], nElem - nCopied ); nCopied += nNew; this->bufs.add ( *pComBuf ); @@ -105,10 +102,7 @@ private: return; } } - pComBuf = new ( std::nothrow ) comBuf; - if ( ! pComBuf ) { - throw std::bad_alloc (); - } + pComBuf = new comBuf; assert ( pComBuf->copyIn ( &val, 1u ) == 1u ); this->bufs.add ( *pComBuf ); if ( ! this->pFirstUncommited.valid() ) { diff --git a/src/ca/nciu.cpp b/src/ca/nciu.cpp index 816879eaa..ebf01b680 100644 --- a/src/ca/nciu.cpp +++ b/src/ca/nciu.cpp @@ -65,9 +65,6 @@ nciu::nciu ( cac & cacIn, netiiu & iiuIn, cacChannelNotify & chanIn, this->nameLength = static_cast ( nameLengthTmp ); this->pNameStr = new char [ this->nameLength ]; - if ( ! this->pNameStr ) { - throw std::bad_alloc (); - } strcpy ( this->pNameStr, pNameIn ); } diff --git a/src/ca/oldCAC.cpp b/src/ca/oldCAC.cpp index 7df81b441..84cebec18 100644 --- a/src/ca/oldCAC.cpp +++ b/src/ca/oldCAC.cpp @@ -27,9 +27,6 @@ oldCAC::oldCAC ( bool enablePreemptiveCallback ) : ca_exception_func ( 0 ), ca_exception_arg ( 0 ), pVPrintfFunc ( errlogVprintf ), fdRegFunc ( 0 ), fdRegArg ( 0 ) { - if ( ! & this->clientCtx ) { - throw std::bad_alloc (); - } } oldCAC::~oldCAC () diff --git a/src/db/dbChannelIO.cpp b/src/db/dbChannelIO.cpp index 9d2ac0595..13c333d6f 100644 --- a/src/db/dbChannelIO.cpp +++ b/src/db/dbChannelIO.cpp @@ -91,12 +91,8 @@ void dbChannelIO::subscribe ( unsigned type, unsigned long count, throw cacChannel::outOfBounds(); } - dbSubscriptionIO *pIO = - new dbSubscriptionIO ( this->serviceIO, *this, - this->addr, notify, type, count, mask, pId ); - if ( ! pIO ) { - throw std::bad_alloc (); - } + new dbSubscriptionIO ( this->serviceIO, *this, + this->addr, notify, type, count, mask, pId ); } void dbChannelIO::ioCancel ( const ioid & id ) diff --git a/src/db/dbServiceIO.cpp b/src/db/dbServiceIO.cpp index 4c192ae6c..3d75b6718 100644 --- a/src/db/dbServiceIO.cpp +++ b/src/db/dbServiceIO.cpp @@ -114,13 +114,7 @@ void dbServiceIO::callStateNotify ( struct dbAddr & addr, // no need to lock this because state notify is // called from only one event queue consumer thread if ( this->stateNotifyCacheSize < size) { - char * pTmp = new ( std::nothrow ) char [size]; - if ( ! pTmp ) { - notify.exception ( ECA_ALLOCMEM, - "unable to allocate callback cache", - type, count ); - return; - } + char * pTmp = new char [size]; delete [] this->pStateNotifyCache; this->pStateNotifyCache = pTmp; this->stateNotifyCacheSize = size; @@ -194,9 +188,6 @@ void dbServiceIO::initiatePutNotify ( epicsGuard < epicsMutex > locker ( this->mutex ); if ( ! chan.dbServicePrivateListOfIO::pBlocker ) { chan.dbServicePrivateListOfIO::pBlocker = new dbPutNotifyBlocker ( chan ); - if ( ! chan.dbServicePrivateListOfIO::pBlocker ) { - throw std::bad_alloc (); - } this->ioTable.add ( *chan.dbServicePrivateListOfIO::pBlocker ); } chan.dbServicePrivateListOfIO::pBlocker->initiatePutNotify ( diff --git a/src/db/dbSubscriptionIO.cpp b/src/db/dbSubscriptionIO.cpp index 32366c5d6..4c49364ed 100644 --- a/src/db/dbSubscriptionIO.cpp +++ b/src/db/dbSubscriptionIO.cpp @@ -41,10 +41,6 @@ dbSubscriptionIO::dbSubscriptionIO ( dbServiceIO &serviceIO, dbChannelIO &chanIO type ( typeIn ), count ( countIn ), id ( 0u ) { this->es = serviceIO.subscribe ( addr, chanIO, *this, maskIn ); - if ( ! this->es ) { - throw std::bad_alloc (); - } - if ( pId ) { *pId = this->getId (); } diff --git a/src/libCom/cxxTemplates/epicsSingletonBase.cpp b/src/libCom/cxxTemplates/epicsSingletonBase.cpp index 331dc581d..4e6c552b0 100644 --- a/src/libCom/cxxTemplates/epicsSingletonBase.cpp +++ b/src/libCom/cxxTemplates/epicsSingletonBase.cpp @@ -32,8 +32,5 @@ void epicsSingletonBase::lockedFactory () epicsGuard < epicsMutex > guard ( this->mutex ); if ( ! this->pSingleton ) { this->pSingleton = this->factory (); - if ( ! this->pSingleton ) { - throw std::bad_alloc (); - } } } \ No newline at end of file diff --git a/src/libCom/cxxTemplates/resourceLib.h b/src/libCom/cxxTemplates/resourceLib.h index 98896dd04..1b9f53d6a 100644 --- a/src/libCom/cxxTemplates/resourceLib.h +++ b/src/libCom/cxxTemplates/resourceLib.h @@ -528,11 +528,14 @@ bool resTable::setTableSizePrivate ( unsigned logBaseTwoTableSizeIn ) # endif const unsigned oldTableOccupiedSize = this->tableSize (); - tsSLList * pNewTable = ( tsSLList * ) - operator new ( newTableSize * sizeof ( tsSLList ), std::nothrow ); - if ( ! pNewTable ) { + tsSLList * pNewTable; + try { + pNewTable = ( tsSLList * ) + ::operator new ( newTableSize * sizeof ( tsSLList ) ); + } + catch ( ... ){ if ( ! this->pTable ) { - throw std::bad_alloc(); + throw; } return false; } @@ -899,14 +902,8 @@ stringId::stringId (const char * idIn, allocationType typeIn) : { if (typeIn==copyString) { unsigned nChars = strlen (idIn) + 1u; - this->pStr = new char [nChars]; - if (this->pStr!=0) { - memcpy ((void *)this->pStr, idIn, nChars); - } - else { - throw std::bad_alloc(); - } + memcpy ( (void *) this->pStr, idIn, nChars ); } else { this->pStr = idIn; diff --git a/src/libCom/cxxTemplates/tsFreeList.h b/src/libCom/cxxTemplates/tsFreeList.h index 402214992..d05e8911d 100644 --- a/src/libCom/cxxTemplates/tsFreeList.h +++ b/src/libCom/cxxTemplates/tsFreeList.h @@ -141,10 +141,7 @@ void * tsFreeList < T, N, MUTEX, DEBUG_LEVEL >::allocate ( size_t size ) } if ( size != sizeof ( T ) || N == 0u || tsFreeListDebugBypass ) { - void *p = ::operator new ( size, std::nothrow ); - if ( ! p ) { - throw std::bad_alloc (); - } + void *p = ::operator new ( size ); if ( tsFreeListDebugBypass ) { memset ( p, 0xaa, size ); } @@ -169,10 +166,7 @@ tsFreeListItem < T, DEBUG_LEVEL > * tsFreeList < T, N, MUTEX, DEBUG_LEVEL >::allocateFromNewChunk () { tsFreeListChunk < T, N, DEBUG_LEVEL > *pChunk = - new ( std::nothrow ) ( tsFreeListChunk < T, N, DEBUG_LEVEL > ); - if ( ! pChunk ) { - throw std::bad_alloc (); - } + new tsFreeListChunk < T, N, DEBUG_LEVEL >; for ( unsigned i=1u; i < N-1; i++ ) { pChunk->items[i].pNext = &pChunk->items[i+1];