bug #65219: (work done by dbaron) r=jag, sr=scc. Remove leaking string recyclers.

This commit is contained in:
scc%mozilla.org 2001-02-23 02:03:02 +00:00
Родитель cc63f5847c
Коммит 97df62b78a
13 изменённых файлов: 52 добавлений и 393 удалений

Просмотреть файл

@ -302,11 +302,11 @@ nsHTMLDocument::~nsHTMLDocument()
mBaseTarget = nsnull;
}
if (nsnull != mLastModified) {
nsString::Recycle(mLastModified);
delete mLastModified;
mLastModified = nsnull;
}
if (nsnull != mReferrer) {
nsString::Recycle(mReferrer);
delete mReferrer;
mReferrer = nsnull;
}
NS_IF_RELEASE(mParser);
@ -1183,7 +1183,7 @@ nsHTMLDocument::SetLastModified(const nsAReadableString& aLastModified)
}
}
else if (nsnull != mLastModified) {
nsString::Recycle(mLastModified);
delete mLastModified;
mLastModified = nsnull;
}
@ -1202,7 +1202,7 @@ nsHTMLDocument::SetReferrer(const nsAReadableString& aReferrer)
}
}
else if (nsnull != mReferrer) {
nsString::Recycle(mReferrer);
delete mReferrer;
mReferrer = nsnull;
}

Просмотреть файл

@ -67,7 +67,7 @@ void nsUnicodeMappingUtil::CleanUp()
for(int i= 0 ; i < smPseudoTotalScripts; i ++) {
for(int j=0; j < 5; j++) {
if(mGenericFontMapping[i][j])
nsString::Recycle(mGenericFontMapping[i][j]);
delete mGenericFontMapping[i][j];
}
}
if (mCache)
@ -326,11 +326,11 @@ PrefEnumCallback(const char* aName, void* aClosure)
if( (! nsDeviceContextMac::GetMacFontNumber(*fontname, fontID)) ||
((script < smUninterp) && (::FontToScript(fontID) != script)))
{
nsString::Recycle(fontname);
delete fontname;
return;
}
if( Self->mGenericFontMapping[script][type] )
nsString::Recycle(Self->mGenericFontMapping[script][type]);
delete Self->mGenericFontMapping[script][type];
Self->mGenericFontMapping[script][type] = fontname;
#ifdef DEBUG_ftang_font
char* utf8 = fontname->ToNewUTF8String();
@ -393,7 +393,7 @@ void nsUnicodeMappingUtil::InitScriptFontMapping()
if (nsDeviceContextMac::GetMacFontNumber (*fontname,fontID))
mScriptFontMapping[script] = fontID;
nsString::Recycle (fontname);
delete fontname;
}
}
}

Просмотреть файл

@ -778,9 +778,6 @@ nsresult nsMsgSearchTerm::MatchRfc2047String (const char *rfc2047string,
res = MatchString(stringToMatch, charset, pResult);
// if (mimedecode == PR_TRUE)
// nsString::Recycle(&decodedString);
return res;
}

Просмотреть файл

@ -545,7 +545,8 @@ nsCString* nsCString::ToNewString() const {
/**
* Creates an ascii clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 02/24/00
* @return ptr to new ascii string
*/
@ -555,7 +556,8 @@ char* nsCString::ToNewCString() const {
/**
* Creates an unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 01/04/99
* @return ptr to new ascii string
*/
@ -1311,94 +1313,6 @@ PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCa
return result;
}
/**************************************************************
Define the string deallocator class...
**************************************************************/
#ifndef RICKG_TESTBED
class nsCStringDeallocator: public nsDequeFunctor{
public:
virtual void* operator()(void* anObject) {
nsCString* aString= (nsCString*)anObject;
if(aString){
delete aString;
}
return 0;
}
};
#endif
/****************************************************************************
* This class, appropriately enough, creates and recycles nsCString objects..
****************************************************************************/
#ifndef RICKG_TESTBED
class nsCStringRecycler {
public:
nsCStringRecycler() : mDeque(0) {
}
~nsCStringRecycler() {
nsCStringDeallocator theDeallocator;
mDeque.ForEach(theDeallocator); //now delete the strings
}
void Recycle(nsCString* aString) {
mDeque.Push(aString);
}
nsCString* CreateString(void){
nsCString* result=(nsCString*)mDeque.Pop();
if(!result)
result=new nsCString();
return result;
}
nsDeque mDeque;
};
static nsCStringRecycler& GetRecycler(void);
/**
*
* @update gess 01/04/99
* @param
* @return
*/
nsCStringRecycler& GetRecycler(void){
static nsCStringRecycler gCRecycler;
return gCRecycler;
}
#endif
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
nsCString* nsCString::CreateString(void){
nsCString* result=0;
#ifndef RICKG_TESTBED
result=GetRecycler().CreateString();
#endif
return result;
}
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
void nsCString::Recycle(nsCString* aString){
#ifndef RICKG_TESTBED
GetRecycler().Recycle(aString);
#endif
}
#if 0
/**

Просмотреть файл

@ -246,14 +246,16 @@ public:
/**
* Creates an ISOLatin1 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new isolatin1 string
*/
char* ToNewCString() const;
/**
* Creates a unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new unicode string
*/
PRUnichar* ToNewUnicode() const;
@ -435,10 +437,6 @@ public:
void DebugDump(void) const;
static void Recycle(nsCString* aString);
static nsCString* CreateString(void);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion

Просмотреть файл

@ -582,7 +582,8 @@ nsString* nsString::ToNewString() const {
/**
* Creates an ascii clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 02/24/00
* @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars!
* @return ptr to new ascii string
@ -599,7 +600,8 @@ char* nsString::ToNewCString() const {
/**
* Creates an UTF8 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update ftang 09/10/99
* @return ptr to new UTF8 string
* http://www.cis.ohio-state.edu/htbin/rfc/rfc2279.html
@ -627,7 +629,8 @@ char* nsString::ToNewUTF8String() const {
/**
* Creates an ascii clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 02/24/00
* @return ptr to new ascii string
*/
@ -1527,90 +1530,6 @@ PRBool nsString::IsDigit(PRUnichar aChar) {
return PRBool((aChar >= '0') && (aChar <= '9'));
}
#ifndef RICKG_TESTBED
/**************************************************************
Define the string deallocator class...
**************************************************************/
class nsStringDeallocator: public nsDequeFunctor{
public:
virtual void* operator()(void* anObject) {
nsString* aString= (nsString*)anObject;
if(aString){
delete aString;
}
return 0;
}
};
/****************************************************************************
* This class, appropriately enough, creates and recycles nsString objects..
****************************************************************************/
class nsStringRecycler {
public:
nsStringRecycler() : mDeque(0) {
}
~nsStringRecycler() {
nsStringDeallocator theDeallocator;
mDeque.ForEach(theDeallocator); //now delete the strings
}
void Recycle(nsString* aString) {
mDeque.Push(aString);
}
nsString* CreateString(void){
nsString* result=(nsString*)mDeque.Pop();
if(!result)
result=new nsString();
return result;
}
nsDeque mDeque;
};
static nsStringRecycler& GetRecycler(void);
/**
*
* @update gess 01/04/99
* @param
* @return
*/
nsStringRecycler& GetRecycler(void){
static nsStringRecycler gRecycler;
return gRecycler;
}
#endif
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
nsString* nsString::CreateString(void){
nsString* result=0;
#ifndef RICKG_TESTBED
GetRecycler().CreateString();
#endif
return result;
}
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
void nsString::Recycle(nsString* aString){
#ifndef RICKG_TESTBED
GetRecycler().Recycle(aString);
#else
delete aString;
#endif
}
#if 0
/**

Просмотреть файл

@ -276,21 +276,24 @@ public:
/**
* Creates an ISOLatin1 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new isolatin1 string
*/
char* ToNewCString() const;
/**
* Creates an UTF8 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new null-terminated UTF8 string
*/
char* ToNewUTF8String() const;
/**
* Creates a unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new unicode string
*/
PRUnichar* ToNewUnicode() const;
@ -506,9 +509,6 @@ public:
*/
static PRBool IsDigit(PRUnichar ch);
static void Recycle(nsString* aString);
static nsString* CreateString(void);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion

Просмотреть файл

@ -168,8 +168,8 @@ nsIMEPreedit::nsIMEPreedit()
nsIMEPreedit::~nsIMEPreedit()
{
mCaretPosition = 0;
nsString::Recycle(mIMECompUnicode);
nsCString::Recycle(mIMECompAttr);
delete mIMECompUnicode;
delete mIMECompAttr;
if (mCompositionUniString) {
delete[] mCompositionUniString;
}

Просмотреть файл

@ -517,9 +517,9 @@ nsWindow::~nsWindow()
// delete any of the IME structures that we allocated
//
if (mIMECompString!=NULL)
nsCString::Recycle(mIMECompString);
delete mIMECompString;
if (mIMECompUnicode!=NULL)
nsString::Recycle(mIMECompUnicode);
delete mIMECompUnicode;
if (mIMEAttributeString!=NULL)
delete [] mIMEAttributeString;
if (mIMECompClauseString!=NULL)

Просмотреть файл

@ -545,7 +545,8 @@ nsCString* nsCString::ToNewString() const {
/**
* Creates an ascii clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 02/24/00
* @return ptr to new ascii string
*/
@ -555,7 +556,8 @@ char* nsCString::ToNewCString() const {
/**
* Creates an unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 01/04/99
* @return ptr to new ascii string
*/
@ -1311,94 +1313,6 @@ PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCa
return result;
}
/**************************************************************
Define the string deallocator class...
**************************************************************/
#ifndef RICKG_TESTBED
class nsCStringDeallocator: public nsDequeFunctor{
public:
virtual void* operator()(void* anObject) {
nsCString* aString= (nsCString*)anObject;
if(aString){
delete aString;
}
return 0;
}
};
#endif
/****************************************************************************
* This class, appropriately enough, creates and recycles nsCString objects..
****************************************************************************/
#ifndef RICKG_TESTBED
class nsCStringRecycler {
public:
nsCStringRecycler() : mDeque(0) {
}
~nsCStringRecycler() {
nsCStringDeallocator theDeallocator;
mDeque.ForEach(theDeallocator); //now delete the strings
}
void Recycle(nsCString* aString) {
mDeque.Push(aString);
}
nsCString* CreateString(void){
nsCString* result=(nsCString*)mDeque.Pop();
if(!result)
result=new nsCString();
return result;
}
nsDeque mDeque;
};
static nsCStringRecycler& GetRecycler(void);
/**
*
* @update gess 01/04/99
* @param
* @return
*/
nsCStringRecycler& GetRecycler(void){
static nsCStringRecycler gCRecycler;
return gCRecycler;
}
#endif
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
nsCString* nsCString::CreateString(void){
nsCString* result=0;
#ifndef RICKG_TESTBED
result=GetRecycler().CreateString();
#endif
return result;
}
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
void nsCString::Recycle(nsCString* aString){
#ifndef RICKG_TESTBED
GetRecycler().Recycle(aString);
#endif
}
#if 0
/**

Просмотреть файл

@ -246,14 +246,16 @@ public:
/**
* Creates an ISOLatin1 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new isolatin1 string
*/
char* ToNewCString() const;
/**
* Creates a unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new unicode string
*/
PRUnichar* ToNewUnicode() const;
@ -435,10 +437,6 @@ public:
void DebugDump(void) const;
static void Recycle(nsCString* aString);
static nsCString* CreateString(void);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion

Просмотреть файл

@ -582,7 +582,8 @@ nsString* nsString::ToNewString() const {
/**
* Creates an ascii clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 02/24/00
* @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars!
* @return ptr to new ascii string
@ -599,7 +600,8 @@ char* nsString::ToNewCString() const {
/**
* Creates an UTF8 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update ftang 09/10/99
* @return ptr to new UTF8 string
* http://www.cis.ohio-state.edu/htbin/rfc/rfc2279.html
@ -627,7 +629,8 @@ char* nsString::ToNewUTF8String() const {
/**
* Creates an ascii clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @update gess 02/24/00
* @return ptr to new ascii string
*/
@ -1527,90 +1530,6 @@ PRBool nsString::IsDigit(PRUnichar aChar) {
return PRBool((aChar >= '0') && (aChar <= '9'));
}
#ifndef RICKG_TESTBED
/**************************************************************
Define the string deallocator class...
**************************************************************/
class nsStringDeallocator: public nsDequeFunctor{
public:
virtual void* operator()(void* anObject) {
nsString* aString= (nsString*)anObject;
if(aString){
delete aString;
}
return 0;
}
};
/****************************************************************************
* This class, appropriately enough, creates and recycles nsString objects..
****************************************************************************/
class nsStringRecycler {
public:
nsStringRecycler() : mDeque(0) {
}
~nsStringRecycler() {
nsStringDeallocator theDeallocator;
mDeque.ForEach(theDeallocator); //now delete the strings
}
void Recycle(nsString* aString) {
mDeque.Push(aString);
}
nsString* CreateString(void){
nsString* result=(nsString*)mDeque.Pop();
if(!result)
result=new nsString();
return result;
}
nsDeque mDeque;
};
static nsStringRecycler& GetRecycler(void);
/**
*
* @update gess 01/04/99
* @param
* @return
*/
nsStringRecycler& GetRecycler(void){
static nsStringRecycler gRecycler;
return gRecycler;
}
#endif
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
nsString* nsString::CreateString(void){
nsString* result=0;
#ifndef RICKG_TESTBED
GetRecycler().CreateString();
#endif
return result;
}
/**
* Call this mehod when you're done
* @update gess 01/04/99
* @param
* @return
*/
void nsString::Recycle(nsString* aString){
#ifndef RICKG_TESTBED
GetRecycler().Recycle(aString);
#else
delete aString;
#endif
}
#if 0
/**

Просмотреть файл

@ -276,21 +276,24 @@ public:
/**
* Creates an ISOLatin1 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new isolatin1 string
*/
char* ToNewCString() const;
/**
* Creates an UTF8 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new null-terminated UTF8 string
*/
char* ToNewUTF8String() const;
/**
* Creates a unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* Note that calls to this method should be matched with calls to
* |nsMemory::Free|.
* @return ptr to new unicode string
*/
PRUnichar* ToNewUnicode() const;
@ -506,9 +509,6 @@ public:
*/
static PRBool IsDigit(PRUnichar ch);
static void Recycle(nsString* aString);
static nsString* CreateString(void);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion