From 77ae5ddcb62369fdf4750d3c84c444cb396c00d3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 27 Mar 2002 14:56:47 +0000 Subject: [PATCH] Updates to various files, replacing delete calls with osgDelete so that greater debugging info can be gleaned. --- src/osg/DisplaySettings.cpp | 2 +- src/osg/GeoSet.cpp | 24 ++++++++++++------------ src/osgDB/FieldReaderIterator.cpp | 8 ++++---- src/osgDB/FileUtils.cpp | 2 +- src/osgDB/Registry.cpp | 2 +- src/osgText/FTBitmapGlyph.cpp | 2 +- src/osgText/FTPixmapGlyph.cpp | 2 +- src/osgUtil/NvTriStripObjects.cpp | 6 +++--- src/osgUtil/NvTriStripObjects.h | 4 +++- 9 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/osg/DisplaySettings.cpp b/src/osg/DisplaySettings.cpp index 72afe65c4..c110b6d09 100644 --- a/src/osg/DisplaySettings.cpp +++ b/src/osg/DisplaySettings.cpp @@ -11,7 +11,7 @@ class DisplaySettingsPtr DisplaySettingsPtr() : _ptr(0L) {} DisplaySettingsPtr(DisplaySettings* t): _ptr(t) {} DisplaySettingsPtr(const DisplaySettingsPtr& rp):_ptr(rp._ptr) { } - ~DisplaySettingsPtr() { if (_ptr) delete _ptr; _ptr=0L; } + ~DisplaySettingsPtr() { if (_ptr) osgDelete _ptr; _ptr=0L; } inline DisplaySettings* get() { return _ptr; } diff --git a/src/osg/GeoSet.cpp b/src/osg/GeoSet.cpp index 9f39a2ebd..0fe3abcc9 100644 --- a/src/osg/GeoSet.cpp +++ b/src/osg/GeoSet.cpp @@ -15,7 +15,7 @@ using namespace osg; GeoSet::GeoSet() { - // we will use the a default delete functor which + // we will use the a default osgDelete functor which // assumes that users have allocated arrays with new only // and that now sharing of attributes exists between GeoSet's. _adf = osgNew AttributeDeleteFunctor; @@ -144,19 +144,19 @@ GeoSet::GeoSet(const GeoSet& geoset,const CopyOp& copyop): void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset) { - // note, delete checks for NULL so want delete NULL pointers. - delete [] gset->getPrimLengths(); - delete [] gset->getCoords(); - delete [] gset->getNormals(); - delete [] gset->getColors(); - delete [] gset->getTextureCoords(); - // can't delete a void* right now... interleaved arrays needs to be reimplemented with a proper pointer.. - // delete [] gset->getInterleavedArray(); + // note, osgDelete checks for NULL so want osgDelete NULL pointers. + osgDelete [] gset->getPrimLengths(); + osgDelete [] gset->getCoords(); + osgDelete [] gset->getNormals(); + osgDelete [] gset->getColors(); + osgDelete [] gset->getTextureCoords(); + // can't osgDelete a void* right now... interleaved arrays needs to be reimplemented with a proper pointer.. + // osgDelete [] gset->getInterleavedArray(); // coord indicies may be shared so we have to go through the long winded // step of creating unique pointer sets which we then delete. This - // ensures that arrays aren't delete twice. Robert. + // ensures that arrays aren't osgDelete twice. Robert. std::set ushortList; std::set uintList; @@ -170,14 +170,14 @@ void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset) sitr!=ushortList.end(); ++sitr) { - delete [] *sitr; + osgDelete [] *sitr; } for(std::set::iterator iitr=uintList.begin(); iitr!=uintList.end(); ++iitr) { - delete [] *iitr; + osgDelete [] *iitr; } } diff --git a/src/osgDB/FieldReaderIterator.cpp b/src/osgDB/FieldReaderIterator.cpp index 656375084..d2e01ac98 100644 --- a/src/osgDB/FieldReaderIterator.cpp +++ b/src/osgDB/FieldReaderIterator.cpp @@ -34,16 +34,16 @@ void FieldReaderIterator::_free() // free all data if (_previousField) { - delete _previousField; + osgDelete _previousField; } if (_fieldQueue) { for(int i=0;i<_fieldQueueCapacity;++i) { - if (_fieldQueue[i]) delete _fieldQueue[i]; + if (_fieldQueue[i]) osgDelete _fieldQueue[i]; _fieldQueue[i] = NULL; } - delete [] _fieldQueue; + osgDelete [] _fieldQueue; } _init(); @@ -258,7 +258,7 @@ FieldReaderIterator& FieldReaderIterator::operator += (int no) { _fieldQueue[_fieldQueueSize+i] = tmpFields[i]; } - delete [] tmpFields; + osgDelete [] tmpFields; } return *this; } diff --git a/src/osgDB/FileUtils.cpp b/src/osgDB/FileUtils.cpp index 589a5e974..3216ec7cd 100644 --- a/src/osgDB/FileUtils.cpp +++ b/src/osgDB/FileUtils.cpp @@ -294,7 +294,7 @@ char *osgDB::findDSO( const char *name ) strcat(prependosgPlugins,name); fileFound = findFileInPath( prependosgPlugins , path ); - delete [] prependosgPlugins; + osgDelete [] prependosgPlugins; return fileFound; #else // defined macintosh diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 88800dc95..2552f886b 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -25,7 +25,7 @@ class RegistryPtr RegistryPtr() : _ptr(0L) {} RegistryPtr(Registry* t): _ptr(t) {} RegistryPtr(const RegistryPtr& rp):_ptr(rp._ptr) { } - ~RegistryPtr() { if (_ptr) delete _ptr; _ptr=0L; } + ~RegistryPtr() { if (_ptr) osgDelete _ptr; _ptr=0L; } inline Registry* get() { return _ptr; } diff --git a/src/osgText/FTBitmapGlyph.cpp b/src/osgText/FTBitmapGlyph.cpp index d95bbd587..f8ff94b00 100644 --- a/src/osgText/FTBitmapGlyph.cpp +++ b/src/osgText/FTBitmapGlyph.cpp @@ -52,7 +52,7 @@ FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph) FTBitmapGlyph::~FTBitmapGlyph() { - delete[] data; + osgDelete [] data; } diff --git a/src/osgText/FTPixmapGlyph.cpp b/src/osgText/FTPixmapGlyph.cpp index 108ff5499..c41866327 100644 --- a/src/osgText/FTPixmapGlyph.cpp +++ b/src/osgText/FTPixmapGlyph.cpp @@ -64,7 +64,7 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph) FTPixmapGlyph::~FTPixmapGlyph() { - delete[] data; + osgDelete [] data; } diff --git a/src/osgUtil/NvTriStripObjects.cpp b/src/osgUtil/NvTriStripObjects.cpp index c244d00fd..82f2b7ad5 100644 --- a/src/osgUtil/NvTriStripObjects.cpp +++ b/src/osgUtil/NvTriStripObjects.cpp @@ -30,7 +30,7 @@ VertexCache::VertexCache(int size) VertexCache::~VertexCache() { - delete[] entries; + osgDelete [] entries; } @@ -832,7 +832,7 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& } osgDelete vcache; - delete[] bVisitedList; + osgDelete [] bVisitedList; } @@ -1634,7 +1634,7 @@ MyVertexVec& optimizedVerts) } } - delete[] indexCache; + osgDelete [] indexCache; assert(optimizedVerts.size() == vertices.size()); } diff --git a/src/osgUtil/NvTriStripObjects.h b/src/osgUtil/NvTriStripObjects.h index 7931654dc..1a799624f 100644 --- a/src/osgUtil/NvTriStripObjects.h +++ b/src/osgUtil/NvTriStripObjects.h @@ -6,6 +6,8 @@ #include #include +#include + ///////////////////////////////////////////////////////////////////////////////// // // Types defined for stripification @@ -133,7 +135,7 @@ class NvEdgeInfo } // ref and unref - void Unref () { if (--m_refCount == 0) delete this; } + void Unref () { if (--m_refCount == 0) osgDelete this; } // data members are left public UINT m_refCount;