Hi,

     the buffer coming the transcode call must be deleted by "delete [] sp;"
and not by the simple delete sp;
If it works for you it's by an accident.

Radovan

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, 31 May, 2001 11:32 PM
Subject: RE: Problem deleting transcoded data


> I gather the app uses all static libraries except for xerces.
> On Solaris this should not be a problem as the following code
> demonstrates:
> /* transcode_test.cpp */
> #include <iostream>
> #include <util/PlatformUtils.hpp>
> #include <dom/DOMString.hpp>
>
> int main(int argc, char *argv[])
> {
>   XMLPlatformUtils::Initialize();
>   DOMString s("Some text!\n");
>
>   char *sp = s.transcode();
>   std::cout << sp;
>
>   delete sp;
>   std::cout << "transcode() string deleted\n";
>   return 0;
> }
> /**********************/
> $ CC -g transcode_test.cpp \
> -I<xerces_headers_dir> \
> -L<libxerces-c1_4_dir> -R<libxerces-c1_4_dir> \
> -lxerces-c1_4 -Bstatic
> $ dump -Lv a.out|grep NEEDED
> [1]     NEEDED      libxerces-c1_4.so
> $ a.out
> Some text!
> transcode() string deleted
>
> Zartaj
>
> -----Original Message-----
> From: Mitchell, Raymond [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 31, 2001 10:51 AM
> To: '[EMAIL PROTECTED]'
> Subject: Problem deleting transcoded data
>
>
> The project I am working on makes use of Xerces-C on Win2000, Solaris, and
> Mac.  I have run into a problem on Windows and Solaris.  When I attempt to
> delete the memory allocated during a transcode, I get an illegal memory
> access.
>
> On Win2000, my project makes use of the Multithreaded runtime library.
This
> cannot be changed, so I linked Xerces-C to the Multithreaded runtime
library
> as well (instead of the Multithreaded DLL runtime library which is the
> default).  This prevented the mixing of runtimes, but the error persisted.
> After digging throught the MSDN, I discovered that a DLL that links to the
> Multithreaded runtime library will allocate its own heap, independent of
the
> heap allocated by applications that use the DLL.  This happens even though
> both the application and DLL link to the Multithreaded runtime library.
> Since Xerces-C is distributed as a DLL, the pointer returned from
> Transcode() references memory allocated in the DLL's heap.  An error
occurs
> when an attempt is made to delete this pointer from an application using
the
> DLL.
>
> So to use Xerces-C on Windows, one has basically has two options:  1) To
> convert Xerces-C to a statically linked library, so that the heap used by
> Xerces-C is the same as that of the application, or 2) To have your
> application use the Multithreaded DLL runtime library so that once again
the
> heaps are the same.
>
> I have received the same problem on UNIX and am currently in the process
of
> converting Xerces-C from a shared to static library.
>
> Has anyone else run into these problems?  Do these problems exist on Mac
as
> well (I haven't implemented the code there yet)?  Would a possible
solution
> to all this be to provide a method on DOMString that takes a pointer to
the
> memory returned by Transcode() and deletes it for you?
>
> Thanks for any help,
> Ray
>
> ---------------------------------------------------------------------
> 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]

Reply via email to