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 Joseph Chen <Jo...@plumtree.com> on 2000/04/27 23:07:05 UTC
Memory leak fixes?
About the memory leaks on exiting, can some of these be fixed rather
quickly?
For instance,
Right now the gMappings hash table is not being deleted.
In TransService.cpp,
static RefHashTableOf<ENameMap>* gMappings = 0;
could be changed to:
static RefHashTableOf<ENameMap> gMappings(103);
and all the gMapping->put or gMapping->get's changed to gMapping.put and
gMapping.get.
Another source of memory leak on exiting is in Win32TransService2.cpp:
if (isAlias(encodingKey, aliasBuf, nameBufSz))
{
const unsigned int srcLen = strlen(aliasBuf);
const unsigned int targetLen = ::mbstowcs(0, aliasBuf, srcLen);
XMLCh* uniAlias = new XMLCh[targetLen + 1];
::mbstowcs(uniAlias, aliasBuf, srcLen);
uniAlias[targetLen] = 0;
::wcsupr(uniAlias);
// Look up the alias name
CPMapEntry* aliasedEntry = gCPMap.get(uniAlias);
if (aliasedEntry)
{
//
// If the name is actually different, then take it.
// Otherwise, don't take it. They map aliases that are
// just different case.
//
if (::wcscmp(uniAlias, aliasedEntry->getEncodingName()))
{
CPMapEntry* newEntry = new CPMapEntry
(
uniAlias
, aliasedEntry->getWinCP()
, aliasedEntry->getIEEncoding()
);
gCPMap.put(newEntry);
}
}
else {
delete [] uniAlias;
}
The uniAlias is never deleted in the case where aliasedEntry is true. Can
we safely take out the else case and have the delete [] uniAlias call every
single time?
Furthermore, I've noticed that the DomStringHandle blocks of memory are not
deleted on exiting. What would be the best way to fix this?
Joseph Chen
Plumtree Software, Inc
http://www.plumtree.com
415-399-2502 direct
For an online demonstration,
go to: http://demo.plumtree.com