changeset 1625:803c80da9d37

Cookies_delete_node
author corvid <corvid@lavabit.com>
date Sun, 21 Mar 2010 23:52:59 +0000
parents d7761a69d274
children fcf42389aa4d
files dpi/cookies.c
diffstat 1 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/dpi/cookies.c	Sun Mar 21 23:49:00 2010 +0000
+++ b/dpi/cookies.c	Sun Mar 21 23:52:59 2010 +0000
@@ -172,6 +172,17 @@
 }
 
 /*
+ * Delete node. This will not free any cookies that might be in node->cookies.
+ */
+static void Cookies_delete_node(DomainNode *node)
+{
+   dList_remove(domains, node);
+   dFree(node->domain);
+   dList_free(node->cookies);
+   dFree(node);
+}
+
+/*
  * Return a file pointer. If the file doesn't exist, try to create it,
  * with the optional 'init_str' as its content.
  */
@@ -397,10 +408,7 @@
 
          Cookies_free_cookie(cookie);
       }
-      dList_remove(domains, node);
-      dFree(node->domain);
-      dList_free(node->cookies);
-      dFree(node);
+      Cookies_delete_node(node);
    }
 
 #ifdef HAVE_LOCKF
@@ -581,12 +589,8 @@
          dList_append(domain_cookies, cookie);
       }
    }
-   if (domain_cookies && (dList_length(domain_cookies) == 0)) {
-      dList_remove(domains, node);
-      dFree(node->domain);
-      dList_free(domain_cookies);
-      dFree(node);
-   }
+   if (domain_cookies && (dList_length(domain_cookies) == 0))
+      Cookies_delete_node(node);
 }
 
 /*
@@ -1103,12 +1107,8 @@
          }
       }
 
-      if (dList_length(domain_cookies) == 0) {
-         dList_remove(domains, node);
-         dFree(node->domain);
-         dList_free(domain_cookies);
-         dFree(node);
-      }
+      if (dList_length(domain_cookies) == 0)
+         Cookies_delete_node(node);
    }
 }