diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-07-06 15:34:31 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-07-06 11:23:35 -0700 |
commit | ae60fdf815d1febe36b5f43642a28afbaf84362b (patch) | |
tree | 20e33d82b358bab3fb582969c455e188683c1cf4 /core/profile.c | |
parent | 69be1e23f231081e6bad98903c10782faf5104a7 (diff) | |
download | subsurface-ae60fdf815d1febe36b5f43642a28afbaf84362b.tar.gz |
Cleanup: call calculate_max_limits_new() in create_plot_info_new()
All callers of create_plot_info_new() called calculate_max_limits_new()
a line before. Thus, simply call the latter in the former.
This allows us to automatically free the plot data in create_plot_info_new().
The old code overwrote the corresponding field with NULL.
As a side-effect, this removes a bogus static variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/profile.c')
-rw-r--r-- | core/profile.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/core/profile.c b/core/profile.c index 5f8be02ac..1492949c4 100644 --- a/core/profile.c +++ b/core/profile.c @@ -398,11 +398,10 @@ static void check_setpoint_events(const struct dive *dive, struct divecomputer * } -struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *given_dc) +static void calculate_max_limits_new(struct dive *dive, struct divecomputer *given_dc, struct plot_info *pi) { struct divecomputer *dc = &(dive->dc); bool seen = false; - static struct plot_info pi; int maxdepth = dive->maxdepth.mm; int maxtime = 0; int maxpressure = 0, minpressure = INT_MAX; @@ -478,16 +477,15 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer if (minhr > maxhr) minhr = maxhr; - memset(&pi, 0, sizeof(pi)); - pi.maxdepth = maxdepth; - pi.maxtime = maxtime; - pi.maxpressure = maxpressure; - pi.minpressure = minpressure; - pi.minhr = minhr; - pi.maxhr = maxhr; - pi.mintemp = mintemp; - pi.maxtemp = maxtemp; - return pi; + memset(pi, 0, sizeof(*pi)); + pi->maxdepth = maxdepth; + pi->maxtime = maxtime; + pi->maxpressure = maxpressure; + pi->minpressure = minpressure; + pi->minhr = minhr; + pi->maxhr = maxhr; + pi->mintemp = mintemp; + pi->maxtemp = maxtemp; } /* copy the previous entry (we know this exists), update time and depth @@ -1337,6 +1335,7 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo UNUSED(planner_ds); #endif free_plot_info_data(pi); + calculate_max_limits_new(dive, dc, pi); get_dive_gas(dive, &o2, &he, &o2max); if (dc->divemode == FREEDIVE){ pi->dive_type = FREEDIVE; |