mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
69be1e23f2
commit
ae60fdf815
4 changed files with 12 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -73,7 +73,6 @@ struct ev_select {
|
|||
bool plot_ev;
|
||||
};
|
||||
|
||||
struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *given_dc);
|
||||
void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int bufsize, int sum);
|
||||
struct plot_info *analyze_plot_info(struct plot_info *pi);
|
||||
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, struct deco_state *planner_ds);
|
||||
|
|
|
@ -202,7 +202,6 @@ static void save_profiles_buffer(struct membuffer *b, bool select_only)
|
|||
for_each_dive(i, dive) {
|
||||
if (select_only && !dive->selected)
|
||||
continue;
|
||||
pi = calculate_max_limits_new(dive, &dive->dc);
|
||||
create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state);
|
||||
put_headers(b);
|
||||
put_format(b, "\n");
|
||||
|
@ -221,7 +220,6 @@ void save_subtitles_buffer(struct membuffer *b, struct dive *dive, int offset, i
|
|||
struct plot_info pi;
|
||||
struct deco_state *planner_deco_state = NULL;
|
||||
|
||||
pi = calculate_max_limits_new(dive, &dive->dc);
|
||||
create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state);
|
||||
|
||||
put_format(b, "[Script Info]\n");
|
||||
|
|
|
@ -636,8 +636,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
|||
* shown.
|
||||
*/
|
||||
|
||||
free_plot_info_data(&plotInfo);
|
||||
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
|
||||
// create_plot_info_new() automatically frees old plot data
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state);
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue