зеркало из https://github.com/mozilla/pjs.git
bug #19474, r=ftang. fixes major memory leak of nsCharsetAlias2 object, which is (12) bytes but references a total of {52708} bytes.
This commit is contained in:
Родитель
3f562a6d09
Коммит
e7245bec84
|
@ -135,11 +135,7 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
if( aSource < mCharsetSource) // priority is lower the the current one , just
|
||||
return res;
|
||||
|
||||
nsICharsetAlias* calias = nsnull;
|
||||
res = nsServiceManager::GetService(kCharsetAliasCID,
|
||||
kICharsetAliasIID,
|
||||
(nsISupports**)&calias);
|
||||
|
||||
NS_WITH_SERVICE(nsICharsetAlias, calias, kCharsetAliasCID, &res);
|
||||
NS_ASSERTION( nsnull != calias, "cannot find charset alias");
|
||||
nsAutoString charsetName = aCharset;
|
||||
if( NS_SUCCEEDED(res) && (nsnull != calias))
|
||||
|
@ -152,7 +148,6 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
}
|
||||
// different, need to change it
|
||||
res = calias->GetPreferred(aCharset, charsetName);
|
||||
nsServiceManager::ReleaseService(kCharsetAliasCID, calias);
|
||||
|
||||
if(NS_FAILED(res) && (kCharsetUninitialized == mCharsetSource) )
|
||||
{
|
||||
|
@ -162,10 +157,7 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
mCharset = charsetName;
|
||||
mCharsetSource = aSource;
|
||||
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
nsCOMTypeInfo<nsICharsetConverterManager>::GetIID(),
|
||||
(nsISupports**)&ccm);
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm))
|
||||
{
|
||||
nsIUnicodeDecoder * decoder = nsnull;
|
||||
|
@ -176,7 +168,6 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
|
||||
mUnicodeDecoder = decoder;
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -93,14 +93,17 @@ nsMetaCharsetObserver::nsMetaCharsetObserver()
|
|||
nsresult res;
|
||||
mAlias = nsnull;
|
||||
NS_WITH_SERVICE(nsICharsetAlias, calias, kCharsetAliasCID, &res);
|
||||
if(NS_SUCCEEDED(res))
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
mAlias = calias;
|
||||
NS_ADDREF(mAlias);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
nsMetaCharsetObserver::~nsMetaCharsetObserver()
|
||||
{
|
||||
// should we release mAlias
|
||||
PR_AtomicDecrement(& g_InstanceCount);
|
||||
NS_IF_RELEASE(mAlias);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -135,11 +135,7 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
if( aSource < mCharsetSource) // priority is lower the the current one , just
|
||||
return res;
|
||||
|
||||
nsICharsetAlias* calias = nsnull;
|
||||
res = nsServiceManager::GetService(kCharsetAliasCID,
|
||||
kICharsetAliasIID,
|
||||
(nsISupports**)&calias);
|
||||
|
||||
NS_WITH_SERVICE(nsICharsetAlias, calias, kCharsetAliasCID, &res);
|
||||
NS_ASSERTION( nsnull != calias, "cannot find charset alias");
|
||||
nsAutoString charsetName = aCharset;
|
||||
if( NS_SUCCEEDED(res) && (nsnull != calias))
|
||||
|
@ -152,7 +148,6 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
}
|
||||
// different, need to change it
|
||||
res = calias->GetPreferred(aCharset, charsetName);
|
||||
nsServiceManager::ReleaseService(kCharsetAliasCID, calias);
|
||||
|
||||
if(NS_FAILED(res) && (kCharsetUninitialized == mCharsetSource) )
|
||||
{
|
||||
|
@ -162,10 +157,7 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
mCharset = charsetName;
|
||||
mCharsetSource = aSource;
|
||||
|
||||
nsICharsetConverterManager * ccm = nsnull;
|
||||
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
|
||||
nsCOMTypeInfo<nsICharsetConverterManager>::GetIID(),
|
||||
(nsISupports**)&ccm);
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm))
|
||||
{
|
||||
nsIUnicodeDecoder * decoder = nsnull;
|
||||
|
@ -176,7 +168,6 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc
|
|||
|
||||
mUnicodeDecoder = decoder;
|
||||
}
|
||||
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
Загрузка…
Ссылка в новой задаче