bug 166833 "nsFT2FontCatalog leaks memory"
patch = Andrew Schultz(ajschult@eos.ncsu.edu) r = louie sr = bryner git-svn-id: svn://10.0.0.236/trunk@140683 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
01337f4f00
commit
47895531db
@ -147,6 +147,9 @@ nsFT2FontCatalog::nsFT2FontCatalog()
|
||||
|
||||
nsFT2FontCatalog::~nsFT2FontCatalog()
|
||||
{
|
||||
#if (defined(MOZ_ENABLE_FREETYPE2))
|
||||
FreeGlobals();
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -186,6 +189,7 @@ nsFT2FontCatalog::GetFontCatalogEntries(const nsACString & aFamilyName,
|
||||
entries->InsertElementAt(genericFce, 0);
|
||||
}
|
||||
|
||||
free(fc->fonts);
|
||||
free(fc);
|
||||
*_retval = entries;
|
||||
NS_ADDREF(*_retval);
|
||||
@ -539,9 +543,36 @@ nsFT2FontCatalog::FreeFontCatalog(nsFontCatalog *fc)
|
||||
fce = fc->fonts[i];
|
||||
FreeFontCatalogEntry(fce);
|
||||
}
|
||||
free(fc->fonts);
|
||||
free(fc);
|
||||
}
|
||||
|
||||
void
|
||||
nsFT2FontCatalog::FreeDirCatalog(nsDirCatalog *dc)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<dc->numDirs; i++) {
|
||||
nsDirCatalogEntry *dce;
|
||||
dce = dc->dirs[i];
|
||||
FreeDirCatalogEntry(dce);
|
||||
}
|
||||
free(dc->dirs);
|
||||
free(dc);
|
||||
}
|
||||
|
||||
void
|
||||
nsFT2FontCatalog::FreeDirCatalogEntry(nsDirCatalogEntry *dce)
|
||||
{
|
||||
if (!dce) {
|
||||
NS_ASSERTION(dce, "dce is null");
|
||||
return;
|
||||
}
|
||||
|
||||
FREE_IF(dce->mDirName);
|
||||
free(dce);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsFT2FontCatalog::FreeFontCatalogEntry(nsFontCatalogEntry *fce)
|
||||
{
|
||||
@ -1232,6 +1263,7 @@ nsFT2FontCatalog::InitGlobals(FT_Library lib)
|
||||
GetFontCatalog(lib, mFontCatalog, dirCatalog);
|
||||
NS_TIMELINE_STOP_TIMER("nsFT2FontCatalog::GetFontCatalog");
|
||||
NS_TIMELINE_MARK_TIMER("nsFT2FontCatalog::GetFontCatalog");
|
||||
FreeDirCatalog(dirCatalog);
|
||||
|
||||
FixUpFontCatalog(mFontCatalog);
|
||||
#ifdef DEBUG
|
||||
|
||||
@ -150,6 +150,8 @@ protected:
|
||||
static PRBool FreeFceHashEntry(nsHashKey* aKey, void* aData, void* aClosure);
|
||||
void FreeFontCatalog(nsFontCatalog *fc);
|
||||
static void FreeFontCatalogEntry(nsFontCatalogEntry *);
|
||||
void FreeDirCatalog(nsDirCatalog *dc);
|
||||
void FreeDirCatalogEntry(nsDirCatalogEntry *);
|
||||
static void GetDirsPrefEnumCallback(const char* aName, void* aClosure);
|
||||
int GetFontCatalog(FT_LibraryRec_*, nsFontCatalog *, nsDirCatalog *);
|
||||
PRBool GetFontSummaryName(const nsACString &, const nsACString &,
|
||||
|
||||
@ -68,6 +68,9 @@ nsIFontCatalogService* nsFT2FontNode::sFcs = nsnull;
|
||||
void
|
||||
nsFT2FontNode::FreeGlobals()
|
||||
{
|
||||
nsServiceManager::ReleaseService("@mozilla.org/gfx/xfontcatalogservice;1",
|
||||
sFcs);
|
||||
|
||||
if (mFreeTypeNodes) {
|
||||
mFreeTypeNodes->Reset(FreeNode, nsnull);
|
||||
delete mFreeTypeNodes;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user