зеркало из https://github.com/mozilla/pjs.git
(215094) more memory management tweaks
This commit is contained in:
Родитель
592c8dab93
Коммит
16279124a2
|
@ -598,6 +598,13 @@ nsOperaCookieMigrator::nsOperaCookieMigrator(nsIInputStream* aSourceStream) :
|
||||||
mCurrCookie.expiryTime = 0;
|
mCurrCookie.expiryTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsOperaCookieMigrator::~nsOperaCookieMigrator()
|
||||||
|
{
|
||||||
|
if (mStream)
|
||||||
|
mStream->SetInputStream(nsnull);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsOperaCookieMigrator::Migrate()
|
nsOperaCookieMigrator::Migrate()
|
||||||
{
|
{
|
||||||
|
@ -632,7 +639,7 @@ nsOperaCookieMigrator::Migrate()
|
||||||
mStream->ReadBytes(length, &buf);
|
mStream->ReadBytes(length, &buf);
|
||||||
buf[length] = '\0';
|
buf[length] = '\0';
|
||||||
mDomainStack.AppendElement((void*)buf);
|
mDomainStack.AppendElement((void*)buf);
|
||||||
nsMemory::Free(buf);
|
buf = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END_DOMAIN_SEGMENT:
|
case END_DOMAIN_SEGMENT:
|
||||||
|
@ -642,9 +649,13 @@ nsOperaCookieMigrator::Migrate()
|
||||||
|
|
||||||
// Pop the domain stack
|
// Pop the domain stack
|
||||||
PRUint32 count = mDomainStack.Count();
|
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);
|
mDomainStack.RemoveElementAt(count - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEGIN_PATH_SEGMENT:
|
case BEGIN_PATH_SEGMENT:
|
||||||
|
@ -657,7 +668,7 @@ nsOperaCookieMigrator::Migrate()
|
||||||
mStream->ReadBytes(length, &buf);
|
mStream->ReadBytes(length, &buf);
|
||||||
buf[length] = '\0';
|
buf[length] = '\0';
|
||||||
mPathStack.AppendElement((void*)buf);
|
mPathStack.AppendElement((void*)buf);
|
||||||
nsMemory::Free(buf);
|
buf = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END_PATH_SEGMENT:
|
case END_PATH_SEGMENT:
|
||||||
|
@ -671,9 +682,13 @@ nsOperaCookieMigrator::Migrate()
|
||||||
|
|
||||||
// Pop the path stack
|
// Pop the path stack
|
||||||
PRUint32 count = mPathStack.Count();
|
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);
|
mPathStack.RemoveElementAt(count - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILTERING_INFO:
|
case FILTERING_INFO:
|
||||||
|
@ -707,6 +722,7 @@ nsOperaCookieMigrator::Migrate()
|
||||||
buf[length] = '\0';
|
buf[length] = '\0';
|
||||||
mCurrCookie.id.Assign(buf);
|
mCurrCookie.id.Assign(buf);
|
||||||
nsMemory::Free(buf);
|
nsMemory::Free(buf);
|
||||||
|
buf = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COOKIE_DATA:
|
case COOKIE_DATA:
|
||||||
|
@ -716,6 +732,7 @@ nsOperaCookieMigrator::Migrate()
|
||||||
buf[length] = '\0';
|
buf[length] = '\0';
|
||||||
mCurrCookie.data.Assign(buf);
|
mCurrCookie.data.Assign(buf);
|
||||||
nsMemory::Free(buf);
|
nsMemory::Free(buf);
|
||||||
|
buf = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COOKIE_EXPIRY:
|
case COOKIE_EXPIRY:
|
||||||
|
@ -745,6 +762,7 @@ nsOperaCookieMigrator::Migrate()
|
||||||
mStream->ReadBytes(length, &buf);
|
mStream->ReadBytes(length, &buf);
|
||||||
buf[length] = '\0';
|
buf[length] = '\0';
|
||||||
nsMemory::Free(buf);
|
nsMemory::Free(buf);
|
||||||
|
buf = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COOKIE_VERSION:
|
case COOKIE_VERSION:
|
||||||
|
@ -764,6 +782,26 @@ nsOperaCookieMigrator::Migrate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (1);
|
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
|
nsresult
|
||||||
|
@ -1219,7 +1257,6 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
|
||||||
nsCOMPtr<nsIRDFResource> itemRes;
|
nsCOMPtr<nsIRDFResource> itemRes;
|
||||||
if (entryType == EntryType_BOOKMARK) {
|
if (entryType == EntryType_BOOKMARK) {
|
||||||
if (!name.IsEmpty() && !url.IsEmpty()) {
|
if (!name.IsEmpty() && !url.IsEmpty()) {
|
||||||
nsCAutoString temp; temp.AssignWithConversion(name);
|
|
||||||
rv = aBMS->CreateBookmarkInContainer(name.get(),
|
rv = aBMS->CreateBookmarkInContainer(name.get(),
|
||||||
url.get(),
|
url.get(),
|
||||||
keyword.get(),
|
keyword.get(),
|
||||||
|
|
|
@ -125,7 +125,7 @@ class nsOperaCookieMigrator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsOperaCookieMigrator(nsIInputStream* aSourceStream);
|
nsOperaCookieMigrator(nsIInputStream* aSourceStream);
|
||||||
virtual ~nsOperaCookieMigrator() { };
|
virtual ~nsOperaCookieMigrator();
|
||||||
|
|
||||||
nsresult Migrate();
|
nsresult Migrate();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче