X-Git-Url: http://git.wpitchoune.net/gitweb/?p=ppastats.git;a=blobdiff_plain;f=src%2Fppastats.c;h=5fb0be11cbc28ee4202311ac169660ffd4bdb663;hp=56293d5cceecf4314ab2ec43261d6db0ba5c95e4;hb=0303d0d705cfc2a100403a708fca0e93b12d2a93;hpb=7322824fadde9e95f79c630b70b25a8a660ab503 diff --git a/src/ppastats.c b/src/ppastats.c index 56293d5..5fb0be1 100644 --- a/src/ppastats.c +++ b/src/ppastats.c @@ -183,8 +183,8 @@ static struct daily_download_total **add_total item = malloc(sizeof(struct daily_download_total)); memcpy(item, total, sizeof(struct daily_download_total)); - result = (struct daily_download_total **) - list_add((void **)totals, (void *)item); + result = (struct daily_download_total **)list_add((void **)totals, + (void *)item); free(totals); @@ -194,14 +194,12 @@ static struct daily_download_total **add_total struct daily_download_total **add_totals (struct daily_download_total **total1, struct daily_download_total **total2) { - struct daily_download_total **cur; - struct daily_download_total **result; + struct daily_download_total **cur, **result; result = total1; cur = total2; while (*cur) { result = add_total(result, *cur); - cur++; } @@ -231,9 +229,8 @@ pkg_add_distro(struct package_stats *pkg, if (!pkg_distro) { pkg_distro = distro_stats_new(distro_name); - tmp - = (struct distro_stats **) - list_add((void **)pkg->distros, (void *)pkg_distro); + tmp = (struct distro_stats **)list_add((void **)pkg->distros, + (void *)pkg_distro); free(pkg->distros); pkg->distros = tmp; } @@ -345,6 +342,16 @@ static void distro_stats_free(struct distro_stats *distro) free(distro); } +static void distro_stats_list_free(struct distro_stats **distros) +{ + if (distros) { + while (*distros) { + distro_stats_free(*distros); + distros++; + } + } +} + static void version_stats_free(struct version_stats *version) { struct distro_stats **distros; @@ -374,7 +381,7 @@ static void package_stats_free(struct package_stats *package) } free(package->versions); } - + distro_stats_list_free(package->distros); free(package->name); free(package); }