When trying to load a file, `pHeader->eType == ALLOC_New and eType == ALLOC_NewArray` which is not good. :(
Here's the call to delete in the quit() function in TinyXML:
`delete ( reinterpret_cast<int*>( rep_ ) );`
And the corresponding new in init():
`rep_ = reinterpret_cast<Rep*>( new int );`
Now, obviously, the allocation call would call:
`void* operator new(size_t nSize)`
but it doesn't. Instead, it calls:
`void* operator new(size_t nSize)`
Even when it allocates an array, it still calls the wrong overloaded function, causing my application to leak like a French cheese. Why is this happening?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Which is odd but the types ( int ) match. I don't think the leak is from TinyXML. Did you see something else, or have a code snippet you can file as a bug?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh, I apologize. I did not mention that I'm using a memory leak checker that overloads the new, new, delete, and delete operators.
It's probably a bug on my part, but for some odd reason,
`rep_ = reinterpret_cast<Rep*>( new int );`
is calling the overloaded
`void* operator new(size_t nSize)`
rather than the overloaded
`void* operator new(size_t nSize)`
If you'd like, and you're not too occupied, you can have a look at Evil Steve's code at:
When trying to load a file, `pHeader->eType == ALLOC_New and eType == ALLOC_NewArray` which is not good. :(
Here's the call to delete in the quit() function in TinyXML:
`delete ( reinterpret_cast<int*>( rep_ ) );`
And the corresponding new in init():
`rep_ = reinterpret_cast<Rep*>( new int );`
Now, obviously, the allocation call would call:
`void* operator new(size_t nSize)`
but it doesn't. Instead, it calls:
`void* operator new(size_t nSize)`
Even when it allocates an array, it still calls the wrong overloaded function, causing my application to leak like a French cheese. Why is this happening?
I'm not sure I follow you; this new:
rep_ = reinterpret_cast<Rep*>( new int );
is matched by this delete:
delete ( reinterpret_cast<int*>( rep_ ) );
Which is odd but the types ( int ) match. I don't think the leak is from TinyXML. Did you see something else, or have a code snippet you can file as a bug?
Oh, I apologize. I did not mention that I'm using a memory leak checker that overloads the new, new, delete, and delete operators.
It's probably a bug on my part, but for some odd reason,
`rep_ = reinterpret_cast<Rep*>( new int );`
is calling the overloaded
`void* operator new(size_t nSize)`
rather than the overloaded
`void* operator new(size_t nSize)`
If you'd like, and you're not too occupied, you can have a look at Evil Steve's code at:
<a href="http://members.gamedev.net/EvilSteve/JournalStuff/MemMgr.h">http://members.gamedev.net/EvilSteve/JournalStuff/MemMgr.h</a> and <a href="http://members.gamedev.net/EvilSteve/JournalStuff/MemMgr.cpp">http://members.gamedev.net/EvilSteve/JournalStuff/MemMgr.cpp</a>
<p>Thanks,<br>
Jack</p>