do not free list in the fct
[ppastats.git] / src / lp.c
index e23b77b..11866d7 100644 (file)
--- a/src/lp.c
+++ b/src/lp.c
 
 #include "list.h"
 #include "lp.h"
-
-char *time_to_str(time_t t)
-{
-       char *str;
-       struct tm *tm;
-       size_t ret;
-
-       tm = localtime(&t);
-
-       if (!tm)
-               return NULL;
-
-       str = malloc(strlen("YYYY-MM-DDThh:mm:ss") + 1);
-       ret = strftime(str, strlen("YYYY-MM-DDThh:mm:ss") + 1, "%FT%T", tm);
-
-       if (ret)
-               return str;
-
-       free(str);
-       return NULL;
-}
+#include <ptime.h>
 
 struct distro_series *distro_series_new(const char *name,
                                        const char *version,
@@ -195,7 +175,7 @@ void daily_download_total_list_free(struct daily_download_total **list)
 
 struct bpph **bpph_list_add(struct bpph **list, struct bpph *new)
 {
-       struct bpph **cur, *bpph;
+       struct bpph **cur, *bpph, **result;
 
        if (list)
                for (cur = list; *cur; cur++) {
@@ -205,7 +185,11 @@ struct bpph **bpph_list_add(struct bpph **list, struct bpph *new)
                                return list;
                }
 
-       return (struct bpph **)list_add((void **)list, new);
+       result = (struct bpph **)list_add((void **)list, new);
+
+       free(list);
+
+       return result;
 }
 
 struct bpph **bpph_list_append_list(struct bpph **list1, struct bpph **list2)