Clean up nsLegacyCheck. Bug 237001, patch by Andrew Schultz

<ajschult@mindspring.com>, r=bsmedberg, sr=dveditz
This commit is contained in:
bzbarsky%mit.edu 2004-04-18 17:25:24 +00:00
parent 5b31654c49
commit 4cf9a89b54
3 changed files with 18 additions and 56 deletions

View File

@ -40,9 +40,9 @@
#include "nsLegacyCheck.h"
#include "assert.h"
nsLegacyCheck::nsLegacyCheck() :
mFilename(NULL),
mMessage(NULL),
nsLegacyCheck::nsLegacyCheck(char *aFilename, char *aMessage) :
mFilename(aFilename),
mMessage(aMessage),
mNext(NULL)
{
}
@ -57,34 +57,12 @@ nsLegacyCheck::~nsLegacyCheck()
XI_IF_FREE(mMessage);
}
int
nsLegacyCheck::SetFilename(char *aFilename)
{
if (!aFilename)
return E_PARAM;
mFilename = aFilename;
return OK;
}
char *
nsLegacyCheck::GetFilename()
{
return mFilename;
}
int
nsLegacyCheck::SetMessage(char *aMessage)
{
if (!aMessage)
return E_PARAM;
mMessage = aMessage;
return OK;
}
char *
nsLegacyCheck::GetMessage()
{
@ -107,12 +85,3 @@ nsLegacyCheck::GetNext()
{
return mNext;
}
int
nsLegacyCheck::InitNext()
{
XI_ASSERT((mNext==NULL), "Leaking nsLegacyCheck::mNext!\n");
mNext = NULL;
return OK;
}

View File

@ -46,16 +46,13 @@
class nsLegacyCheck
{
public:
nsLegacyCheck();
nsLegacyCheck(char *aFilename, char *aMessage);
~nsLegacyCheck();
int SetFilename(char *aFilename);
char *GetFilename();
int SetMessage(char *aMessage);
char *GetMessage();
int SetNext(nsLegacyCheck *aNext);
nsLegacyCheck *GetNext();
int InitNext();
private:
char *mFilename;

View File

@ -179,8 +179,9 @@ nsSetupTypeDlg::Parse(nsINIParser *aParser)
char *currLCSec = (char *) malloc(strlen(LEGACY_CHECKd) + 1);
if (!currLCSec) return E_MEM;
char *currVal = NULL;
nsLegacyCheck *currLC = NULL, *lastLC = NULL, *nextLC = NULL;
nsObjectIgnore *currOI = NULL, *lastOI = NULL, *nextOI = NULL;
char *currFile = NULL, *currMsg = NULL;
nsLegacyCheck *currLC = NULL, *nextLC = NULL;
nsComponent *currComp = NULL;
nsComponent *currCompDup = NULL;
int currIndex;
@ -254,8 +255,6 @@ nsSetupTypeDlg::Parse(nsINIParser *aParser)
sObjectsToIgnore = NULL;
/* legacy check */
sLegacyChecks = new nsLegacyCheck();
currLC = sLegacyChecks;
for (i = 0; i < MAX_LEGACY_CHECKS; i++)
{
// construct section name based on index
@ -264,7 +263,7 @@ nsSetupTypeDlg::Parse(nsINIParser *aParser)
// get "Filename" and "Message" keys
bufsize = 0;
err = aParser->GetStringAlloc(currLCSec, FILENAME, &currVal, &bufsize);
err = aParser->GetStringAlloc(currLCSec, FILENAME, &currFile, &bufsize);
if (err != OK)
{
if (err != nsINIParser::E_NO_SEC &&
@ -272,16 +271,12 @@ nsSetupTypeDlg::Parse(nsINIParser *aParser)
else
{
err = OK;
XI_IF_DELETE(currLC);
if (lastLC)
lastLC->InitNext();
break;
}
}
currLC->SetFilename(currVal);
bufsize = 0;
err = aParser->GetStringAlloc(currLCSec, MSG, &currVal, &bufsize);
err = aParser->GetStringAlloc(currLCSec, MSG, &currMsg, &bufsize);
if (err != OK)
{
if (err != nsINIParser::E_NO_SEC &&
@ -289,21 +284,22 @@ nsSetupTypeDlg::Parse(nsINIParser *aParser)
else
{
err = OK;
XI_IF_DELETE(currLC);
if (lastLC)
lastLC->InitNext();
break;
}
}
currLC->SetMessage(currVal);
nextLC = new nsLegacyCheck(currFile, currMsg);
if (currLC)
{
currLC->SetNext(nextLC);
}
else if (!sLegacyChecks)
{
sLegacyChecks = nextLC;
}
nextLC = new nsLegacyCheck();
currLC->SetNext(nextLC);
lastLC = currLC;
currLC = nextLC;
}
if (i == 0) // none found
sLegacyChecks = NULL;
/* setup types */
for (i=0; i<MAX_SETUP_TYPES; i++)