(215094) more memory management tweaks

This commit is contained in:
ben%bengoodger.com 2004-02-29 22:35:37 +00:00
Родитель 592c8dab93
Коммит 16279124a2
2 изменённых файлов: 43 добавлений и 6 удалений

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

@ -598,6 +598,13 @@ nsOperaCookieMigrator::nsOperaCookieMigrator(nsIInputStream* aSourceStream) :
mCurrCookie.expiryTime = 0;
}
nsOperaCookieMigrator::~nsOperaCookieMigrator()
{
if (mStream)
mStream->SetInputStream(nsnull);
};
nsresult
nsOperaCookieMigrator::Migrate()
{
@ -632,7 +639,7 @@ nsOperaCookieMigrator::Migrate()
mStream->ReadBytes(length, &buf);
buf[length] = '\0';
mDomainStack.AppendElement((void*)buf);
nsMemory::Free(buf);
buf = nsnull;
}
break;
case END_DOMAIN_SEGMENT:
@ -642,8 +649,12 @@ nsOperaCookieMigrator::Migrate()
// Pop the domain stack
PRUint32 count = mDomainStack.Count();
if (count > 0)
if (count > 0) {
char* segment = (char*)mDomainStack.ElementAt(count - 1);
if (segment)
nsMemory::Free(segment);
mDomainStack.RemoveElementAt(count - 1);
}
}
break;
@ -657,7 +668,7 @@ nsOperaCookieMigrator::Migrate()
mStream->ReadBytes(length, &buf);
buf[length] = '\0';
mPathStack.AppendElement((void*)buf);
nsMemory::Free(buf);
buf = nsnull;
}
break;
case END_PATH_SEGMENT:
@ -671,8 +682,12 @@ nsOperaCookieMigrator::Migrate()
// Pop the path stack
PRUint32 count = mPathStack.Count();
if (count > 0)
if (count > 0) {
char* segment = (char*)mPathStack.ElementAt(count - 1);
if (segment)
nsMemory::Free(segment);
mPathStack.RemoveElementAt(count - 1);
}
}
break;
@ -707,6 +722,7 @@ nsOperaCookieMigrator::Migrate()
buf[length] = '\0';
mCurrCookie.id.Assign(buf);
nsMemory::Free(buf);
buf = nsnull;
}
break;
case COOKIE_DATA:
@ -716,6 +732,7 @@ nsOperaCookieMigrator::Migrate()
buf[length] = '\0';
mCurrCookie.data.Assign(buf);
nsMemory::Free(buf);
buf = nsnull;
}
break;
case COOKIE_EXPIRY:
@ -745,6 +762,7 @@ nsOperaCookieMigrator::Migrate()
mStream->ReadBytes(length, &buf);
buf[length] = '\0';
nsMemory::Free(buf);
buf = nsnull;
}
break;
case COOKIE_VERSION:
@ -764,6 +782,26 @@ nsOperaCookieMigrator::Migrate()
}
}
while (1);
// Make sure the path and domain stacks are clear.
char* segment = nsnull;
PRUint32 i;
PRUint32 count = mPathStack.Count();
for (i = 0; i < count; ++i) {
segment = (char*)mPathStack.ElementAt(i);
if (segment) {
nsMemory::Free(segment);
segment = nsnull;
}
}
count = mDomainStack.Count();
for (i = 0; i < count; ++i) {
segment = (char*)mDomainStack.ElementAt(i);
if (segment) {
nsMemory::Free(segment);
segment = nsnull;
}
}
}
nsresult
@ -1219,7 +1257,6 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
nsCOMPtr<nsIRDFResource> itemRes;
if (entryType == EntryType_BOOKMARK) {
if (!name.IsEmpty() && !url.IsEmpty()) {
nsCAutoString temp; temp.AssignWithConversion(name);
rv = aBMS->CreateBookmarkInContainer(name.get(),
url.get(),
keyword.get(),

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

@ -125,7 +125,7 @@ class nsOperaCookieMigrator
{
public:
nsOperaCookieMigrator(nsIInputStream* aSourceStream);
virtual ~nsOperaCookieMigrator() { };
virtual ~nsOperaCookieMigrator();
nsresult Migrate();