I recently downloaded the latest version of TinyXML, and have encountered compile errors that I havn't had with previous versions (The last version I downloaded was around May time this year)
I override the new operator with the following code
#ifdef _DEBUG
#define MARY_DEBUG_NEW new(__FILE__, __LINE__)
#else
#define MARY_DEBUG_NEW new
#endif
#define new MARY_DEBUG_NEW
I then use the following overrides to allow for custom memory management.
new(size_t size, const char *_file, int _line)
new[](size_t size, const char *_file, int _line)
new(size_t size)
new[](size_t size)
Unfortunatly, I know have a problem in tinystr.h, line 220 (rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));)
Due to the new operator taking a size param, it throws my memeory management functions out of the window, and cannot find a suitable function to call.
Are you aware of a solution for this?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Its not clean but why not change the new() on line 220 to something like new_1, then #define new_1 to be your debug version but with the extra parameter?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-10-18
That was one idea I toyed with, but I went with the simpler option of including tinyxml.h before my new defines (which means they use the standard heap).
This method compiles and works, but doesnt use my heap functions, which is the ideal, as it deals with more than just tracking memory leaks.
Spree
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After additional thought, it might just be simplest to go with:
rep_ = static_cast<Rep*>(new int[enough mem])
The integer allocation should guarentee 32 bit alignment for platforms that care about that sort of thing, and it would allocate from the normal array allocator.
The cast is no more safe, or unsafe, than the current one. Over-ridden new/delete should work again as expected.
lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I recently downloaded the latest version of TinyXML, and have encountered compile errors that I havn't had with previous versions (The last version I downloaded was around May time this year)
I override the new operator with the following code
#ifdef _DEBUG
#define MARY_DEBUG_NEW new(__FILE__, __LINE__)
#else
#define MARY_DEBUG_NEW new
#endif
#define new MARY_DEBUG_NEW
I then use the following overrides to allow for custom memory management.
new(size_t size, const char *_file, int _line)
new[](size_t size, const char *_file, int _line)
new(size_t size)
new[](size_t size)
Unfortunatly, I know have a problem in tinystr.h, line 220 (rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));)
Due to the new operator taking a size param, it throws my memeory management functions out of the window, and cannot find a suitable function to call.
Are you aware of a solution for this?
Thanks
Its not clean but why not change the new() on line 220 to something like new_1, then #define new_1 to be your debug version but with the extra parameter?
That was one idea I toyed with, but I went with the simpler option of including tinyxml.h before my new defines (which means they use the standard heap).
This method compiles and works, but doesnt use my heap functions, which is the ideal, as it deals with more than just tracking memory leaks.
Spree
That's a good catch and something I want to fix. (On some unusual systems structure aligment requirements could get confused as well.)
On the other hand, the intent to only have one memory allocation is a good one.
Hmm.
Any other ideas on how to get this to work with one memory allocator but not confuse the overrides?
lee
After additional thought, it might just be simplest to go with:
rep_ = static_cast<Rep*>(new int[enough mem])
The integer allocation should guarentee 32 bit alignment for platforms that care about that sort of thing, and it would allocate from the normal array allocator.
The cast is no more safe, or unsafe, than the current one. Over-ridden new/delete should work again as expected.
lee
This bug was troubling me. I just fixed 2.4.1 which fixes this bug and a CDATA output bug.
lee
Excellent
Any idea when this will be updated in the CVS server to I can download it and check how it goes?