From 59224e484253b32432743248672d8d8ba69f110b Mon Sep 17 00:00:00 2001
From: Aleksey Veresov <aleksey@veresov.pro>
Date: Sat, 30 Nov 2019 18:53:03 +0300
Subject: [magi] fix

---
 src/cookie.c  |  5 ++---
 src/cookie.h  |  3 +--
 src/request.c | 11 +++++++++++
 src/request.h |  6 ++++++
 4 files changed, 20 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/cookie.c b/src/cookie.c
index eaa221f..9d2a5ce 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -16,13 +16,12 @@ int magi_cookie_list_add(struct magi_cookie_list ** list,
     return !!node;
 }
 
-struct magi_cookie * magi_cookie_list_get(struct magi_cookie_list * list,
-                                          const char *              name)
+char * magi_cookie_list_get(struct magi_cookie_list * list, const char * name)
 {
     if (!list || !name) {
         return 0;
     } else if (!strcmp(list->item.name, name)) {
-        return &list->item;
+        return list->item.data;
     } else {
         return magi_cookie_list_get(list->next, name);
     }
diff --git a/src/cookie.h b/src/cookie.h
index 82c914e..764eb53 100644
--- a/src/cookie.h
+++ b/src/cookie.h
@@ -22,8 +22,7 @@ int magi_cookie_list_add(struct magi_cookie_list ** list,
                          struct magi_cookie *       item);
 
 /* First node in list: node.name == name; else null. */
-struct magi_cookie * magi_cookie_list_get(struct magi_cookie_list * list,
-                                          const char *              name);
+char * magi_cookie_list_get(struct magi_cookie_list * list, const char * name);
 
 /* Freeing and invalidation of list. */
 void magi_cookie_list_destroy(struct magi_cookie_list * list);
diff --git a/src/request.c b/src/request.c
index e905e53..0db1e70 100644
--- a/src/request.c
+++ b/src/request.c
@@ -21,6 +21,7 @@ void magi_request_setup(struct magi_request * request)
     }
 }
 
+
 void magi_tempfiles_add(struct magi_tempfiles * tmps,
                         const char *            name,
                         const char *            path,
@@ -46,6 +47,16 @@ void magi_tempfiles_add(struct magi_tempfiles * tmps,
     tmps->maximums[tmps->count - 1]    = max;
 }
 
+void magi_tempfiles_destroy(struct magi_tempfiles * tmps)
+{
+    if (!tmps) {
+        return;
+    }
+    free(tmps->param_names);
+    free(tmps->locations);
+    free(tmps->maximums);
+}
+
 static void tempfiles(struct magi_file * file,
                       char *             addon,
                       int                addon_len,
diff --git a/src/request.h b/src/request.h
index be92370..0ac7bac 100644
--- a/src/request.h
+++ b/src/request.h
@@ -82,21 +82,27 @@ struct magi_request {
 /* Setup request with default settings. */
 void magi_request_setup(struct magi_request * request);
 
+
 struct magi_tempfiles {
     int           count;
     const char ** param_names;
     const char ** locations;
     int *         maximums; /* Null maximums[i] <=> unlimited tempfiles[i]. */
 };
+
 void magi_tempfiles_add(struct magi_tempfiles * tmps,
                         const char *            name,
                         const char *            path,
                         int                     max);
+
+void magi_tempfiles_destroy(struct magi_tempfiles * tmps);
+
 /* Setup request callback with files loaded into corresponding to their
  * parameter names locations; paths are in magi_tempfiles struct. */
 void magi_request_setup_tempfiles(struct magi_request *   request,
                                   struct magi_tempfiles * table);
 
+
 /* Destroys request. */
 void magi_request_destroy(struct magi_request * request);
 
-- 
cgit v1.2.3