fix up deletion code for cookie viewer

This commit is contained in:
morse%netscape.com 1999-08-10 18:13:55 +00:00
Родитель 9db5447de6
Коммит d50dab93cd
1 изменённых файлов: 34 добавлений и 68 удалений

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

@ -515,11 +515,10 @@ cookie_RemoveAllPermissions() {
return;
}
PRInt32 count = cookie_permissionList->Count();
for (PRInt32 i = 0; i < count; ++i) {
for (PRInt32 i = count-1; i >=0; i--) {
victim = NS_STATIC_CAST(cookie_PermissionStruct*, cookie_permissionList->ElementAt(i));
if (victim) {
cookie_FreePermission(victim, PR_FALSE);
i = -1;
}
}
delete cookie_permissionList;
@ -527,9 +526,7 @@ cookie_RemoveAllPermissions() {
cookie_UnlockPermissionListst();
}
/* This should only get called while holding the cookie-lock
**
*/
/* This should only get called while holding the cookie-lock */
PRIVATE void
cookie_FreeCookie(cookie_CookieStruct * cookie) {
if(!cookie) {
@ -561,11 +558,10 @@ cookie_RemoveAllCookies() {
return;
}
PRInt32 count = cookie_cookieList->Count();
for (PRInt32 i = 0; i < count; ++i) {
for (PRInt32 i = count-1; i >=0; i--) {
victim = NS_STATIC_CAST(cookie_CookieStruct*, cookie_cookieList->ElementAt(i));
if (victim) {
cookie_FreeCookie(victim);
i = -1;
}
}
delete cookie_cookieList;
@ -576,7 +572,6 @@ cookie_RemoveAllCookies() {
PUBLIC void
COOKIE_RemoveAllCookies()
{
cookie_RemoveAllPermissions();
cookie_RemoveAllCookies();
}
@ -2145,7 +2140,6 @@ cookie_FindValueInArgs(nsAutoString results, char* name) {
nsAutoString value;
PRInt32 start, length;
start = results.Find(name);
// XP_ASSERT(start >= 0);
NS_ASSERTION(start >= 0, "bad data");
if (start < 0) {
return nsAutoString("").ToNewCString();
@ -2159,67 +2153,40 @@ cookie_FindValueInArgs(nsAutoString results, char* name) {
PUBLIC void
COOKIE_CookieViewerReturn(nsAutoString results) {
cookie_CookieStruct * cookie;
cookie_CookieStruct * cookieToDelete = 0;
cookie_PermissionStruct * permission;
cookie_PermissionStruct * permissionToDelete = 0;
int cookieNumber;
int permissionNumber;
PRInt32 count = 0;
/* step through all cookies and delete those that are in the sequence
* Note: we can't delete cookie while "cookie_ptr" is pointing to it because
* that would destroy "cookie_ptr". So we do a lazy deletion
*/
/* step through all cookies and delete those that are in the sequence */
char * gone = cookie_FindValueInArgs(results, "|goneC|");
cookieNumber = 0;
cookie_LockCookieList();
if (cookie_cookieList) {
count = cookie_cookieList->Count();
for (PRInt32 i = 0; i < count; ++i) {
cookie = NS_STATIC_CAST(cookie_CookieStruct*, cookie_cookieList->ElementAt(i));
if (cookie) {
if (cookie_InSequence(gone, cookieNumber)) {
if (cookieToDelete) {
cookie_FreeCookie(cookieToDelete);
while (count>0) {
count--;
cookie = NS_STATIC_CAST(cookie_CookieStruct*, cookie_cookieList->ElementAt(count));
if (cookie && cookie_InSequence(gone, count)) {
cookie_FreeCookie(cookie);
}
cookieToDelete = cookie;
}
cookieNumber++;
}
}
if (cookieToDelete) {
cookie_FreeCookie(cookieToDelete);
cookie_SaveCookies();
}
}
cookie_UnlockCookieList();
delete[] gone;
/* step through all permissions and delete those that are in the sequence
* Note: we can't delete permission while "permission_ptr" is pointing to it because
* that would destroy "permission_ptr". So we do a lazy deletion
*/
/* step through all permissions and delete those that are in the sequence */
gone = cookie_FindValueInArgs(results, "|goneP|");
permissionNumber = 0;
cookie_LockPermissionList();
if (cookie_permissionList) {
count = cookie_permissionList->Count();
for (PRInt32 i = 0; i < count; ++i) {
permission = NS_STATIC_CAST(cookie_PermissionStruct*, cookie_permissionList->ElementAt(i));
if (permission) {
if (cookie_InSequence(gone, permissionNumber)) {
if (permissionToDelete) {
cookie_FreePermission(permissionToDelete, PR_FALSE);
}
permissionToDelete = permission;
}
permissionNumber++;
while (count>0) {
count--;
permission = NS_STATIC_CAST(cookie_PermissionStruct*, cookie_permissionList->ElementAt(count));
if (permission && cookie_InSequence(gone, count)) {
cookie_FreePermission(permission, PR_FALSE);
cookie_permissionsChanged = PR_TRUE;
}
}
if (permissionToDelete) {
cookie_FreePermission(permissionToDelete, PR_TRUE);
}
}
cookie_SavePermissions();
cookie_UnlockPermissionListst();
delete[] gone;
}
@ -2407,7 +2374,6 @@ cookie_ParseDate(char *date_string) {
// TRACEMSG(("Parsing date string: %s\n",date_string));
/* try using PR_ParseTimeString instead */
if(PR_ParseTimeString(date_string, PR_TRUE, &prdate) == PR_SUCCESS) {
PRInt64 r, u;
LL_I2L(u, PR_USEC_PER_SEC);