core: C++-ify statistics.c

The old code was wild: For the yearly statistics it would allocate
one entry per dive in the log. Of course, it would also leak
C-style strings.

Convert the whole thing to somewhat idiomatic C++.

Somewhat wasted work, because I'd like to convert the whole thing
to the new statistics code. But let's finish the conversion to C++
first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-01 23:16:00 +02:00 committed by bstoeger
parent 84219641de
commit 1daa4f0584
12 changed files with 496 additions and 582 deletions

View file

@ -123,10 +123,9 @@ QString TemplateLayout::generateStatistics()
State state;
int i = 0;
stats_summary_auto_free stats;
calculate_stats_summary(&stats, false);
while (stats.stats_yearly != NULL && stats.stats_yearly[i].period) {
state.years.append(&stats.stats_yearly[i]);
stats_summary stats = calculate_stats_summary(false);
for (auto &s: stats.stats_yearly) {
state.years.append(&s);
i++;
}