Added support for osg::MemoryManager which is based upon Paul Nettle's
memory manager published at flipcode.com. This can be turned on with the OSG_USE_MEMORY_MANGER option which then uses custom global new and delete operators as well as provide osgNew and osgDelete macro's which add ability to log line and file from which calls are made. Updated osg,osgUtil,osgDB,osgText and osgPlugins/osg to use osgNew/osgDelete, and fixed memory leaks highlighted by the new memory manager.
This commit is contained in:
@@ -66,17 +66,17 @@ void FieldReaderIterator::_copy(const FieldReaderIterator& ic)
|
||||
|
||||
if (ic._previousField)
|
||||
{
|
||||
_previousField = new Field(*ic._previousField);
|
||||
_previousField = osgNew Field(*ic._previousField);
|
||||
}
|
||||
|
||||
if (ic._fieldQueue && ic._fieldQueueCapacity>0)
|
||||
{
|
||||
_fieldQueue = new Field* [ic._fieldQueueCapacity];
|
||||
_fieldQueue = osgNew Field* [ic._fieldQueueCapacity];
|
||||
for(int i=0;i<ic._fieldQueueCapacity;++i)
|
||||
{
|
||||
if (ic._fieldQueue[i])
|
||||
{
|
||||
_fieldQueue[i] = new Field(*ic._fieldQueue[i]);
|
||||
_fieldQueue[i] = osgNew Field(*ic._fieldQueue[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -128,7 +128,7 @@ void FieldReaderIterator::insert(int pos,Field* field)
|
||||
int newCapacity = _fieldQueueCapacity*2;
|
||||
if (newCapacity<MINIMUM_FIELD_READER_QUEUE_SIZE) newCapacity = MINIMUM_FIELD_READER_QUEUE_SIZE;
|
||||
while(_fieldQueueSize>=newCapacity) newCapacity*=2;
|
||||
Field** newFieldStack = new Field* [newCapacity];
|
||||
Field** newFieldStack = osgNew Field* [newCapacity];
|
||||
for(i=0;i<_fieldQueueCapacity;++i)
|
||||
{
|
||||
newFieldStack[i] = _fieldQueue[i];
|
||||
@@ -154,7 +154,7 @@ void FieldReaderIterator::insert(int pos,const char* str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
Field* field = new Field;
|
||||
Field* field = osgNew Field;
|
||||
while(*str!=0)
|
||||
{
|
||||
field->addChar(*str);
|
||||
@@ -190,7 +190,7 @@ Field& FieldReaderIterator::field (int pos)
|
||||
int newCapacity = _fieldQueueCapacity*2;
|
||||
if (newCapacity<MINIMUM_FIELD_READER_QUEUE_SIZE) newCapacity = MINIMUM_FIELD_READER_QUEUE_SIZE;
|
||||
while(_fieldQueueSize>=newCapacity) newCapacity*=2;
|
||||
Field** newFieldStack = new Field* [newCapacity];
|
||||
Field** newFieldStack = osgNew Field* [newCapacity];
|
||||
int i;
|
||||
for(i=0;i<_fieldQueueCapacity;++i)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ Field& FieldReaderIterator::field (int pos)
|
||||
}
|
||||
while(!_reader.eof() && pos>=_fieldQueueSize)
|
||||
{
|
||||
if (_fieldQueue[_fieldQueueSize]==NULL) _fieldQueue[_fieldQueueSize] = new Field;
|
||||
if (_fieldQueue[_fieldQueueSize]==NULL) _fieldQueue[_fieldQueueSize] = osgNew Field;
|
||||
if (_reader.readField(*_fieldQueue[_fieldQueueSize]))
|
||||
{
|
||||
++_fieldQueueSize;
|
||||
@@ -243,7 +243,7 @@ FieldReaderIterator& FieldReaderIterator::operator += (int no)
|
||||
}
|
||||
else if (no>0)
|
||||
{
|
||||
Field** tmpFields = new Field* [no];
|
||||
Field** tmpFields = osgNew Field* [no];
|
||||
int i;
|
||||
for(i=0;i<no;++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user