diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-07-06 12:59:12 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-09 19:19:04 +0100 |
commit | 2fd4cb5fe1415a204610b89b22c0863c0703175e (patch) | |
tree | cab34a6dc57376b0447b1124b199e8b9566ca460 /core/profile.c | |
parent | fe6d3c8c3803378fa9369dd6dfb5ec2fa5a0086f (diff) | |
download | subsurface-2fd4cb5fe1415a204610b89b22c0863c0703175e.tar.gz |
Profile: pass index instead of pointer to set_plot_pressure_data
Another plot-pressure-related function whose argument is converted
to an index.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/profile.c')
-rw-r--r-- | core/profile.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/core/profile.c b/core/profile.c index 413b1abde..a012eb0cf 100644 --- a/core/profile.c +++ b/core/profile.c @@ -599,9 +599,9 @@ static void populate_plot_entries(struct dive *dive, struct divecomputer *dc, st entry->pressures.o2 = sample->setpoint.mbar / 1000.0; } if (sample->pressure[0].mbar) - set_plot_pressure_data(entry, SENSOR_PR, sample->sensor[0], sample->pressure[0].mbar); + set_plot_pressure_data(pi, idx, SENSOR_PR, sample->sensor[0], sample->pressure[0].mbar); if (sample->pressure[1].mbar) - set_plot_pressure_data(entry, SENSOR_PR, sample->sensor[1], sample->pressure[1].mbar); + set_plot_pressure_data(pi, idx, SENSOR_PR, sample->sensor[1], sample->pressure[1].mbar); if (sample->temperature.mkelvin) entry->temperature = lasttemp = sample->temperature.mkelvin; else @@ -816,18 +816,12 @@ static void populate_secondary_sensor_data(const struct divecomputer *dc, struct */ static void add_plot_pressure(struct plot_info *pi, int time, int cyl, pressure_t p) { - struct plot_data *entry; - if (pi->nr <= 0) { - fprintf(stderr, "add_plot_pressure(): called with pi->nr <= 0\n"); - return; - } for (int i = 0; i < pi->nr; i++) { - entry = pi->entry + i; - - if (entry->sec >= time) - break; + if (i == pi->nr - 1 || pi->entry[i].sec >= time) { + set_plot_pressure_data(pi, i, SENSOR_PR, cyl, p.mbar); + return; + } } - set_plot_pressure_data(entry, SENSOR_PR, cyl, p.mbar); } static void setup_gas_sensor_pressure(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi) |