style
[ppastats.git] / src / ppastats.c
index 754cf4e..7acc059 100644 (file)
@@ -1,20 +1,20 @@
 /*
* Copyright (C) 2011-2014 jeanfi@gmail.com
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
- *
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
- *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
+  Copyright (C) 2011-2014 jeanfi@gmail.com
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 2 of the
+  License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+  02110-1301 USA
  */
 
 #include <libintl.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "list.h"
-#include "lp_ws.h"
+#include <list.h>
+#include <lp_ws.h>
 #include <plog.h>
-#include "ppastats.h"
+#include <ppastats.h>
 
 static struct package_stats *get_package_stats(struct ppa_stats *stats,
                                               const char *name)
@@ -228,7 +228,8 @@ pkg_add_distro(struct package_stats *pkg,
                pkg_distro = distro_stats_new(distro_name);
                tmp = (struct distro_stats **)list_add((void **)pkg->distros,
                                                       (void *)pkg_distro);
-               free(pkg->distros);
+               if (pkg->distros != tmp)
+                       free(pkg->distros);
                pkg->distros = tmp;
        }
 
@@ -367,22 +368,13 @@ static void distro_stats_list_free(struct distro_stats **distros)
                        distro_stats_free(*distros);
                        distros++;
                }
+               free(distros);
        }
 }
 
 static void version_stats_free(struct version_stats *version)
 {
-       struct distro_stats **distros;
-
-       distros = version->distros;
-       if (distros) {
-               while (*distros) {
-                       distro_stats_free(*distros);
-                       distros++;
-               }
-               free(version->distros);
-       }
-
+       distro_stats_list_free(version->distros);
        daily_download_total_list_free(version->daily_download_totals);
 
        free(version->version);