I am not sure. I wondered the same thing when I ran into this problem.
Perhaps someone else knows the answer to this?
Ray
-----Original Message-----
From: Bruce Bailey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 9:19 AM
To: '[EMAIL PROTECTED]'
Subject: RE: Correct Way to dispose of strings from XMLString::transcode
Ray
Thanks so much for the information. I ran a simple test with a one-function
DLL and verified that this is indeed the problem.
I must be missing something however. This seems like a problem that most
Win programmers are going to run into. Why aren't the standard distribution
packages for windows using static libraries rather than DLL's?
Thanks,
Bruce
> -----Original Message-----
> From: Mitchell, Raymond [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 13, 2001 3:54 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Correct Way to dispose of strings from
> XMLString::transcode
>
>
> When linking to Xerces-C, you must make sure you are linking
> with the same
> runtime library that the Xerces-C DLL links with. The
> Xerces-C DLL links to
> the multithreaded DLL version of the runtime library by
> default. To use the
> Xerces-C DLL as it ships, your program must link to the
> multithreaded DLL
> version of the runtime library as well.
>
> Visual C++ provides three versions of the runtime libraries:
> multithreaded
> DLL, multithreaded static, singlethreaded static. If your
> program cannot be
> linked to the multithreaded DLL runtime library, then it must
> be linking to
> one of the two static libraries. You cannot simply rebuild
> the Xerces-C DLL
> to link with the same static library as your program. This
> is because DLL's
> are seperately linkable units (the same as executables).
> Even though both
> your program and Xerces-C would be linking to the same static runtime
> library, each would maintain its own heap. It would be
> illegal for the
> memory returned by Xerces-C to be deleted by your program.
>
> The way around this is to recompile Xerces-C as a statically
> linked library
> (create a new project of type "Static Library" in Visual
> C++). Link your
> program to the static library version of Xerces-C and
> everything should work
> fine. The static library version of Xerces-C will now
> actually be part of
> your program and hence share the same heap with it.
>
> I hope this helps,
> Ray
>
> -----Original Message-----
> From: Bruce Bailey [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 13, 2001 2:25 PM
> To: 'Xerces List'
> Subject: Correct Way to dispose of strings from XMLString::transcode
>
>
> Hi
>
> When trying to run the following program, I keep getting an
> invalid heap
> pointer error. This occurs whenever I try to delete either
> the XML string
> or the normal string. If I don't use 'delete', I get memory
> leaks. Any
> ideas as to what might be the problem?
>
> Thanks.
>
> Bruce
>
> Platform: Winnt 4.0 (not sure of sp level, but I think it's 5)
> Compiler: vc 6.0
> Xerces version: VER=1_4
>
> #include <util\XMLString.hpp>
> #include <util/PlatformUtils.hpp>
>
> int
> main(int argc, char *argv[])
> {
> XMLPlatformUtils::Initialize();
>
> XMLCh *x = XMLString::transcode("This is a test");
> char *p = XMLString::transcode(x);
>
> delete x; /* delete[] x doesn't work either*/
> delete[]p;
>
> XMLPlatformUtils::Terminate();
>
> return 0;
> }
>
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]