diff options
author | 2018-10-06 16:30:57 +0200 | |
---|---|---|
committer | 2018-10-07 17:50:51 +0300 | |
commit | b61f6f66d8859e62023e3818879b90de529e9a72 (patch) | |
tree | 3f504976833a99d518886f0059ca6b28504b8c8b /core/statistics.c | |
parent | 97991e2b9fff4254c2b40417bf6d7496ba0d849f (diff) | |
download | subsurface-b61f6f66d8859e62023e3818879b90de529e9a72.tar.gz |
Statistics: un-globalize stats_selection
The statistics of the selected dives were calculated
a) into a global objects and
b) at a completely different place than where they're used.
There's no plausible reason for either. There fore render
into a caller-provided structure at the place of use.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/statistics.c')
-rw-r--r-- | core/statistics.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/statistics.c b/core/statistics.c index b7e4e1f4c..5d9c8049a 100644 --- a/core/statistics.c +++ b/core/statistics.c @@ -4,6 +4,7 @@ * core logic for the Info & Stats page - * char *get_minutes(int seconds); * void calculate_stats_summary(struct stats_summary *out); + * void calculate_stats_selected(stats_t *stats_selection); */ #include "gettext.h" #include <string.h> @@ -14,8 +15,6 @@ #include "divelist.h" #include "statistics.h" -stats_t stats_selection; - static void process_temperatures(struct dive *dp, stats_t *stats) { temperature_t min_temp, mean_temp, max_temp = {.mkelvin = 0}; @@ -224,21 +223,21 @@ void init_stats_summary(struct stats_summary *stats) } /* make sure we skip the selected summary entries */ -void process_selected_dives(void) +void calculate_stats_selected(stats_t *stats_selection) { struct dive *dive; unsigned int i, nr; - memset(&stats_selection, 0, sizeof(stats_selection)); + memset(stats_selection, 0, sizeof(*stats_selection)); nr = 0; for_each_dive(i, dive) { if (dive->selected) { - process_dive(dive, &stats_selection); + process_dive(dive, stats_selection); nr++; } } - stats_selection.selection_size = nr; + stats_selection->selection_size = nr; } #define SOME_GAS 5000 // 5bar drop in cylinder pressure makes cylinder used |