dont hide global new with placement new/delete

This commit is contained in:
Jeff Hill
2002-04-25 22:19:05 +00:00
parent aab783d387
commit 35deb5810c
7 changed files with 86 additions and 147 deletions

View File

@@ -25,10 +25,6 @@
# if _MSC_VER >= 1200
# define NETIO_PLACEMENT_DELETE
# endif
#elif defined (__GNUC__) && 0
# if __GNUC__>2 || ( __GNUC__==2 && __GNUC_MINOR_>=96 )
# define NETIO_PLACEMENT_DELETE
# endif
#else
# define NETIO_PLACEMENT_DELETE
#endif
@@ -89,6 +85,8 @@ private:
netSubscription ( nciu &chan, unsigned type, arrayElementCount count,
unsigned mask, cacStateNotify &notify );
class netSubscription * isSubscription ();
void * operator new ( size_t );
void operator delete ( void * );
void * operator new ( size_t,
tsFreeList < class netSubscription, 1024, epicsMutexNOOP > & );
# if defined ( NETIO_PLACEMENT_DELETE )
@@ -98,12 +96,6 @@ private:
netSubscription ( const netSubscription & );
netSubscription & operator = ( const netSubscription & );
~netSubscription ();
# if defined (_MSC_VER) && _MSC_VER <= 1300
void operator delete ( void * ); // avoid visual c++ 7 bug
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void operator delete ( void *, size_t ); // avoid gnu g++ bug
# endif
};
class netReadNotifyIO : public baseNMIU {
@@ -122,6 +114,8 @@ public:
private:
cacReadNotify & notify;
netReadNotifyIO ( nciu & chan, cacReadNotify & notify );
void * operator new ( size_t );
void operator delete ( void * );
void * operator new ( size_t,
tsFreeList < class netReadNotifyIO, 1024, epicsMutexNOOP > & );
# if defined ( NETIO_PLACEMENT_DELETE )
@@ -131,12 +125,6 @@ private:
~netReadNotifyIO ();
netReadNotifyIO ( const netReadNotifyIO & );
netReadNotifyIO & operator = ( const netReadNotifyIO & );
# if defined (_MSC_VER) && _MSC_VER <= 1300
void operator delete ( void * ); // avoid visual c++ 7 bug
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void operator delete ( void *, size_t ); // avoid gnu g++ bug
# endif
};
class netWriteNotifyIO : public baseNMIU {
@@ -155,6 +143,8 @@ public:
private:
cacWriteNotify &notify;
netWriteNotifyIO ( nciu &chan, cacWriteNotify &notify );
void * operator new ( size_t );
void operator delete ( void * );
void * operator new ( size_t,
tsFreeList < class netWriteNotifyIO, 1024, epicsMutexNOOP > & );
# if defined ( NETIO_PLACEMENT_DELETE )
@@ -164,12 +154,6 @@ private:
netWriteNotifyIO ( const netWriteNotifyIO & );
netWriteNotifyIO & operator = ( const netWriteNotifyIO & );
~netWriteNotifyIO ();
# if defined (_MSC_VER) && _MSC_VER <= 1300
void operator delete ( void * ); // avoid visual c++ 7 bug
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void operator delete ( void *, size_t ); // avoid gnu g++ bug
# endif
};
inline ca_uint32_t baseNMIU::getID () const
@@ -188,6 +172,24 @@ inline void * netSubscription::operator new ( size_t size,
return freeList.allocate ( size );
}
#if defined ( NETIO_PLACEMENT_DELETE )
inline void netSubscription::operator delete ( void *pCadaver,
tsFreeList < class netSubscription, 1024, epicsMutexNOOP > &freeList )
{
freeList.release ( pCadaver, sizeof ( netSubscription ) );
}
#endif
inline void * netSubscription::operator new ( size_t sizeIn )
{
return ::operator new ( sizeIn );
}
inline void netSubscription::operator delete ( void * p )
{
::operator delete ( p );
}
inline netSubscription * netSubscription::factory (
tsFreeList < class netSubscription, 1024, epicsMutexNOOP > &freeList,
nciu &chan, unsigned type, arrayElementCount count,
@@ -231,6 +233,24 @@ inline void * netReadNotifyIO::operator new ( size_t size,
return freeList.allocate ( size );
}
#if defined ( NETIO_PLACEMENT_DELETE )
inline void netReadNotifyIO::operator delete ( void *pCadaver,
tsFreeList < class netReadNotifyIO, 1024, epicsMutexNOOP > &freeList )
{
freeList.release ( pCadaver, sizeof ( netWriteNotifyIO ) );
}
#endif
inline void * netReadNotifyIO::operator new ( size_t sizeIn )
{
return ::operator new ( sizeIn );
}
inline void netReadNotifyIO::operator delete ( void * p )
{
::operator delete ( p );
}
inline netWriteNotifyIO * netWriteNotifyIO::factory (
tsFreeList < class netWriteNotifyIO, 1024, epicsMutexNOOP > &freeList,
nciu &chan, cacWriteNotify &notify )
@@ -244,4 +264,22 @@ inline void * netWriteNotifyIO::operator new ( size_t size,
return freeList.allocate ( size );
}
#if defined ( NETIO_PLACEMENT_DELETE )
inline void netWriteNotifyIO::operator delete ( void *pCadaver,
tsFreeList < class netWriteNotifyIO, 1024, epicsMutexNOOP > &freeList )
{
freeList.release ( pCadaver, sizeof ( netWriteNotifyIO ) );
}
#endif
inline void * netWriteNotifyIO::operator new ( size_t sizeIn )
{
return ::operator new ( sizeIn );
}
inline void netWriteNotifyIO::operator delete ( void * p )
{
::operator delete ( p );
}
#endif // ifdef netIOh

View File

@@ -64,31 +64,3 @@ void netReadNotifyIO::completion ( unsigned type,
this->notify.completion ( type, count, pData );
}
// NOTE: The constructor for netReadNotifyIO::netReadNotifyIO() currently does
// not throw an exception, but we should eventually have placement delete
// defined for class netReadNotifyIO when compilers support this so that
// there is no possibility of a leak if there was an exception in
// a future version of netReadNotifyIO::netReadNotifyIO()
#if defined ( NETIO_PLACEMENT_DELETE )
void netReadNotifyIO::operator delete ( void *pCadaver,
tsFreeList < class netReadNotifyIO, 1024, epicsMutexNOOP > & freeList ) {
freeList.release ( pCadaver, sizeof ( netReadNotifyIO ) );
}
#endif
# if defined (_MSC_VER) && _MSC_VER <= 1300
void netReadNotifyIO::operator delete ( void * ) // avoid visual c++ 7 bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void netReadNotifyIO::operator delete ( void *, size_t ) // avoid gnu g++ bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif

View File

@@ -82,32 +82,8 @@ void netSubscription::completion ( unsigned typeIn,
this->notify.current ( typeIn, countIn, pDataIn );
}
// NOTE: The constructor for netSubscription::netSubscription() currently does
// not throw an exception, but we should eventually have placement delete
// defined for class netSubscription when compilers support this so that
// there is no possibility of a leak if there was an exception in
// a future version of netSubscription::netSubscription()
#if defined ( NETIO_PLACEMENT_DELETE )
void netSubscription::operator delete ( void *pCadaver,
tsFreeList < class netSubscription, 1024, epicsMutexNOOP > &freeList )
{
freeList.release ( pCadaver, sizeof ( netSubscription ) );
}
#endif
# if defined (_MSC_VER) && _MSC_VER <= 1300
void netSubscription::operator delete ( void * ) // avoid visual c++ 7 bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void netSubscription::operator delete ( void *, size_t ) // avoid gnu g++ bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif

View File

@@ -65,33 +65,3 @@ void netWriteNotifyIO::completion ( unsigned /* type */,
this->chan.getClient().printf ( "Write response with data ?\n" );
}
// NOTE: The constructor for netWriteNotifyIO::netWriteNotifyIO() currently does
// not throw an exception, but we should eventually have placement delete
// defined for class netWriteNotifyIO when compilers support this so that
// there is no possibility of a leak if there was an exception in
// a future version of netWriteNotifyIO::netWriteNotifyIO()
#if defined ( NETIO_PLACEMENT_DELETE )
void netWriteNotifyIO::operator delete ( void *pCadaver,
tsFreeList < class netWriteNotifyIO, 1024, epicsMutexNOOP > &freeList )
{
freeList.release ( pCadaver, sizeof ( netWriteNotifyIO ) );
}
#endif
# if defined (_MSC_VER) && _MSC_VER <= 1300
void netWriteNotifyIO::operator delete ( void * ) // avoid visual c++ 7 bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void netWriteNotifyIO::operator delete ( void *, size_t ) // avoid gnu g++ bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif

View File

@@ -89,6 +89,8 @@ protected:
private:
void *pValue;
syncGroupReadNotify ( struct CASG &sgIn, chid, void *pValueIn );
void * operator new ( size_t );
void operator delete ( void * );
void * operator new ( size_t,
tsFreeList < class syncGroupReadNotify, 128, epicsMutexNOOP > & );
# if defined ( CASG_PLACEMENT_DELETE )
@@ -101,12 +103,6 @@ private:
int status, const char *pContext, unsigned type, arrayElementCount count );
syncGroupReadNotify ( const syncGroupReadNotify & );
syncGroupReadNotify & operator = ( const syncGroupReadNotify & );
# if defined (_MSC_VER) && _MSC_VER <= 1300
void operator delete ( void * ); // avoid visual c++ 7 bug
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void operator delete ( void *, size_t ); // avoid gnu g++ bug
# endif
};
class syncGroupWriteNotify : public syncGroupNotify, public cacWriteNotify {
@@ -123,6 +119,8 @@ protected:
private:
void *pValue;
syncGroupWriteNotify ( struct CASG &, chid );
void * operator new ( size_t );
void operator delete ( void * );
void * operator new ( size_t,
tsFreeList < class syncGroupWriteNotify, 128, epicsMutexNOOP > & );
# if defined ( CASG_PLACEMENT_DELETE )
@@ -134,12 +132,6 @@ private:
unsigned type, arrayElementCount count );
syncGroupWriteNotify ( const syncGroupWriteNotify & );
syncGroupWriteNotify & operator = ( const syncGroupWriteNotify & );
# if defined (_MSC_VER) && _MSC_VER <= 1300
void operator delete ( void * ); // avoid visual c++ 7 bug
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void operator delete ( void *, size_t ); // avoid gnu g++ bug
# endif
};
struct oldCAC;

View File

@@ -104,6 +104,16 @@ void syncGroupReadNotify::show ( unsigned level ) const
}
}
void * syncGroupReadNotify::operator new ( size_t sizeIn )
{
return ::operator new ( sizeIn );
}
void syncGroupReadNotify::operator delete ( void * p )
{
::operator delete ( p );
}
void * syncGroupReadNotify::operator new ( size_t size,
tsFreeList < class syncGroupReadNotify, 128, epicsMutexNOOP > & freeList )
{
@@ -117,18 +127,3 @@ void syncGroupReadNotify::operator delete ( void *pCadaver,
freeList.release ( pCadaver, sizeof ( syncGroupReadNotify ) );
}
#endif
# if defined (_MSC_VER) && _MSC_VER <= 1300
void syncGroupReadNotify::operator delete ( void * ) // avoid visual c++ 7 bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void syncGroupReadNotify::operator delete ( void *, size_t ) // avoid gnu g++ bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif

View File

@@ -99,6 +99,16 @@ void syncGroupWriteNotify::show ( unsigned level ) const
}
}
void * syncGroupWriteNotify::operator new ( size_t sizeIn )
{
return ::operator new ( sizeIn );
}
void syncGroupWriteNotify::operator delete ( void * p )
{
::operator delete ( p );
}
void * syncGroupWriteNotify::operator new ( size_t size,
tsFreeList < class syncGroupWriteNotify, 128, epicsMutexNOOP > & freeList )
{
@@ -113,17 +123,3 @@ void syncGroupWriteNotify::operator delete ( void *pCadaver,
}
#endif
# if defined (_MSC_VER) && _MSC_VER <= 1300
void syncGroupWriteNotify::operator delete ( void * ) // avoid visual c++ 7 bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif
# if __GNUC__==2 && __GNUC_MINOR_<=96
void syncGroupWriteNotify::operator delete ( void *, size_t ) // avoid gnu g++ bug
{
throw std::logic_error ( "bogus operator delete called?" );
}
# endif