cookie: introduce yaz_cookies_reset
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 10 Jan 2014 12:57:33 +0000 (13:57 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 10 Jan 2014 12:57:33 +0000 (13:57 +0100)
include/yaz/cookie.h
src/cookie.c

index 8d83809..ed90f2e 100644 (file)
@@ -47,6 +47,7 @@ YAZ_EXPORT void yaz_cookies_response(yaz_cookies_t yc, Z_HTTP_Response *res);
 
 YAZ_EXPORT void yaz_cookies_request(yaz_cookies_t yc, ODR odr,
                                     Z_HTTP_Request *req);
+YAZ_EXPORT void yaz_cookies_reset(yaz_cookies_t yc);
 
 YAZ_END_CDECL
 
index 2a22b2f..6aa0042 100644 (file)
@@ -34,6 +34,12 @@ yaz_cookies_t yaz_cookies_create(void)
 
 void yaz_cookies_destroy(yaz_cookies_t yc)
 {
+    yaz_cookies_reset(yc);
+    xfree(yc);
+}
+
+void yaz_cookies_reset(yaz_cookies_t yc)
+{
     if (yc)
     {
         struct cookie *c = yc->list;
@@ -47,7 +53,7 @@ void yaz_cookies_destroy(yaz_cookies_t yc)
             xfree(c);
             c = c1;
         }
-        xfree(yc);
+        yc->list = 0;
     }
 }