You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Mohammed Zubair <mo...@am.sony.com> on 2001/04/24 20:34:30 UTC
memory leak in transcode ??
Hi,
i have here a small snippet of code which simulates the problem i am
facing.
XMLCh *tlocal;
tlocal = XMLString::transcode("This is a test");
char *c = XMLString::transcode(tlocal);
Problem --> delete [] c;
The problem occurs when i try to free the char c. As i am calling this
transcode function a lot of times in my program, i need to free it, but it
gives me an exception whenever i try to do so.
Any ideas would be highly appreciated.
Program included below.
Thanks.
///Code
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <util/PlatformUtils.hpp>
#include <util/XMLString.hpp>
#include <util/XMLUniDefs.hpp>
int main(int argc, char* argv[]) {
int retval = 0;
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
char *pMessage = XMLString::transcode(toCatch.getMessage());
delete [] pMessage;
return -1;
}
XMLCh *tlocal;
tlocal = XMLString::transcode("This is a test");
char *c = XMLString::transcode(tlocal);
delete [] c;
// And call the termination method
XMLPlatformUtils::Terminate();
return retval;
}
///Code
Mohammed Zubair V
MediaSoft Lab, Sony.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org