I am using xerces 2.8 in C++ API
I created a function to convert to UTF8
void convertToUTF8(const char* buffer, string &utf8_string)
{
XMLTranscoder* utf8Transcoder;
XMLTransService::Codes failReason;
utf8Transcoder =
XMLPlatformUtils::fgTransService->makeNewTranscoderFor("UTF-8", failReason,
16*1024);
size_t len = XMLString::stringLen(buffer);
XMLByte* utf8 = new XMLByte[(len*MB_LEN_MAX)+1];
unsigned int eaten;
unsigned int utf8Len = utf8Transcoder->transcodeTo(X(buffer), len,
utf8, len*MB_LEN_MAX, eaten, XMLTranscoder::UnRep_Throw);
utf8[utf8Len] = '\0';
utf8_string = (char*)utf8;
delete[] utf8;
delete utf8Transcoder;
}
But this function leaks memory when I pass it through the Purify tool to
detect memory leaks.
[I] MPK: Potential memory leak of 4164 bytes from 214 blocks allocated in
xercesc_2_8::MemoryManagerImpl::allocate(UINT) [XERCES-C_2_8D.DLL]
Offset 0x00000008 referenced by 0x122cfd54, a location in a section
in a loaded module
Distribution of potentially leaked blocks
Allocation location
new(UINT)
[f:\sp\vctools\crt_bld\self_x86\crt\src\new.cpp:57]
xercesc_2_8::MemoryManagerImpl::allocate(UINT)
[F:\WORKDIR\MYPARSER\DEBUG\XERCES-C_2_8D.DLL]
Is there something I need to do explicity to release the memory?
Please let me know.
Thanks
PL
--
View this message in context:
http://old.nabble.com/memory-leak-using-XMLTranscoder-tp26314147p26314147.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]