Hi David, For sure we could go this way, and perhaps there's no other solution. But this would mean that we'd have to do a custom build in order to run this test, and this means it would only get run intermittently when people remembered/had cycles for it. Much much better if we could rig something together that we could integrate into our sanity tests that we run nightly on every platform we support + lots of others that we happen to have around.
Cheers, Neil Neil Graham XML Parser Development IBM Toronto Lab Phone: 905-413-3519, T/L 969-3519 E-mail: [EMAIL PROTECTED] |---------+----------------------------> | | David N | | | Bertoni/Cambridge| | | /[EMAIL PROTECTED] | | | | | | 06/02/2003 07:26 | | | PM | | | Please respond to| | | xerces-c-dev | | | | |---------+----------------------------> >---------------------------------------------------------------------------------------------------------------------------------------------| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: Re: in search of ideas: how might one write a test that the parser never calls global new directly? | | | | | >---------------------------------------------------------------------------------------------------------------------------------------------| Hi Neil, Since you're allowed to override global new/delete, why not put an empty implementation within Xerces that calls the panic handler or the default static MemoryManager, and logs a message? I tried this on Win32 (with a little massaging of the code), Linux, and AIX and it seems to work just fine: File NewHack.cpp: #include <cstdio> #include <cstdlib> #include <new> void* operator new( size_t size ) throw(std::bad_alloc) { fprintf(stderr, "Call to global new!!!!!!!!!!!\n"); exit(-1); return 0; } void operator delete( void* ) throw() { fprintf(stderr, "Call to global delete!!!!!!!!!!!\n"); exit(-1); } File TestNew.cpp: #include <new> int main( int argc, const char* argv[]) { int* i = new int(5); delete i; return 0; } You wouldn't want to do this in a production environment, since the library might export the symbols for new and delete, which would affect users' code, but for testing purposes, I think it will work. Dave "Neil Graham" <[EMAIL PROTECTED] To: [EMAIL PROTECTED] m> cc: (bcc: David N Bertoni/Cambridge/IBM) Subject: in search of ideas: how might one write a test that the parser never calls 06/02/2003 03:05 global new directly? PM Please respond to xerces-c-dev Hi folks, Now that we've implemented the new memory management framework, it would be nice to have some confidence that we're using it correctly and comprehensively. I'll shortly commit some tests that exercise per-parser handlers, and ensure that all memory that the handlers allocate is deleted, and that it's deleted by the right handler. But it's a little less clear how we'd write a test to make sure that there aren't any places in the code that are calling global new directly; i.e., it's not completely obvious (to me anyway) how one tests that the pluggable mechanism is always used. Anyone have some thoughts on how one might go about doing this in a compiler/OS agnostic manner? Cheers, Neil Neil Graham XML Parser Development IBM Toronto Lab Phone: 905-413-3519, T/L 969-3519 E-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]