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);
|
struct divecomputer *dc = &(dive->dc);
|
||||||
bool seen = false;
|
bool seen = false;
|
||||||
static struct plot_info pi;
|
|
||||||
int maxdepth = dive->maxdepth.mm;
|
int maxdepth = dive->maxdepth.mm;
|
||||||
int maxtime = 0;
|
int maxtime = 0;
|
||||||
int maxpressure = 0, minpressure = INT_MAX;
|
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)
|
if (minhr > maxhr)
|
||||||
minhr = maxhr;
|
minhr = maxhr;
|
||||||
|
|
||||||
memset(&pi, 0, sizeof(pi));
|
memset(pi, 0, sizeof(*pi));
|
||||||
pi.maxdepth = maxdepth;
|
pi->maxdepth = maxdepth;
|
||||||
pi.maxtime = maxtime;
|
pi->maxtime = maxtime;
|
||||||
pi.maxpressure = maxpressure;
|
pi->maxpressure = maxpressure;
|
||||||
pi.minpressure = minpressure;
|
pi->minpressure = minpressure;
|
||||||
pi.minhr = minhr;
|
pi->minhr = minhr;
|
||||||
pi.maxhr = maxhr;
|
pi->maxhr = maxhr;
|
||||||
pi.mintemp = mintemp;
|
pi->mintemp = mintemp;
|
||||||
pi.maxtemp = maxtemp;
|
pi->maxtemp = maxtemp;
|
||||||
return pi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the previous entry (we know this exists), update time and depth
|
/* 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);
|
UNUSED(planner_ds);
|
||||||
#endif
|
#endif
|
||||||
free_plot_info_data(pi);
|
free_plot_info_data(pi);
|
||||||
|
calculate_max_limits_new(dive, dc, pi);
|
||||||
get_dive_gas(dive, &o2, &he, &o2max);
|
get_dive_gas(dive, &o2, &he, &o2max);
|
||||||
if (dc->divemode == FREEDIVE){
|
if (dc->divemode == FREEDIVE){
|
||||||
pi->dive_type = FREEDIVE;
|
pi->dive_type = FREEDIVE;
|
||||||
|
|
|
@ -73,7 +73,6 @@ struct ev_select {
|
||||||
bool plot_ev;
|
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);
|
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);
|
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);
|
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) {
|
for_each_dive(i, dive) {
|
||||||
if (select_only && !dive->selected)
|
if (select_only && !dive->selected)
|
||||||
continue;
|
continue;
|
||||||
pi = calculate_max_limits_new(dive, &dive->dc);
|
|
||||||
create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state);
|
create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state);
|
||||||
put_headers(b);
|
put_headers(b);
|
||||||
put_format(b, "\n");
|
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 plot_info pi;
|
||||||
struct deco_state *planner_deco_state = NULL;
|
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);
|
create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state);
|
||||||
|
|
||||||
put_format(b, "[Script Info]\n");
|
put_format(b, "[Script Info]\n");
|
||||||
|
|
|
@ -636,8 +636,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
||||||
* shown.
|
* shown.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
free_plot_info_data(&plotInfo);
|
// create_plot_info_new() automatically frees old plot data
|
||||||
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state);
|
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue