/*
- * 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)
result = (struct daily_download_total **)list_add((void **)totals,
ddt_clone(total));
-
return result;
}
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;
}
pkg_distro->ddts = tmp_ddts;
}
+static struct ppa_stats *ppa_stats_new(const char *owner, const char *ppa_name)
+{
+ struct ppa_stats *ppa;
+
+ ppa = malloc(sizeof(struct ppa_stats));
+ ppa->name = strdup(ppa_name);
+ ppa->owner = strdup(owner);
+ ppa->packages = NULL;
+ ppa->daily_download_totals = NULL;
+ ppa->download_count = 0;
+
+ return ppa;
+}
+
struct ppa_stats *
create_ppa_stats(const char *owner,
const char *ppa_name,
exit(EXIT_FAILURE);
}
- ppa = malloc(sizeof(struct ppa_stats));
- ppa->name = strdup(ppa_name);
- ppa->owner = strdup(owner);
- ppa->packages = NULL;
- ppa->daily_download_totals = NULL;
- ppa->download_count = 0;
+ ppa = ppa_stats_new(owner, ppa_name);
for (h_cur = history; *h_cur; ++h_cur) {
h = *h_cur;
free(distro->archs);
}
+ daily_download_total_list_free(distro->ddts);
+
free(distro->name);
free(distro);
}
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);
free(version);
free(package->versions);
}
distro_stats_list_free(package->distros);
+ daily_download_total_list_free(package->daily_download_totals);
free(package->name);
free(package);
}