mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: refactor per_cylinder_mean_depth()
This function had a horrendous interface: The caller would have to allocate two arrays of the correct size to be filled with data. The callee couldn't even check the size, because the data was passed as raw pointers. Instead, use std::vector<>, construct everything in the called function and do size-sanity check in the calling function. Use depth_t and duration_t instead of plain integers to represent mean depth and time. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
dbc06d78b6
commit
9cf753fa56
3 changed files with 54 additions and 49 deletions
|
|
@ -130,6 +130,12 @@ struct dive {
|
|||
fraction_t best_o2(depth_t depth, bool in_planner) const;
|
||||
fraction_t best_he(depth_t depth, bool o2narcotic, fraction_t fo2) const;
|
||||
|
||||
struct depth_duration {
|
||||
depth_t depth;
|
||||
duration_t duration;
|
||||
};
|
||||
std::vector<depth_duration> per_cylinder_mean_depth_and_duration(int dc_nr) const;
|
||||
|
||||
bool dive_has_gps_location() const;
|
||||
location_t get_gps_location() const;
|
||||
|
||||
|
|
@ -193,7 +199,6 @@ extern void copy_events_until(const struct dive *sd, struct dive *dd, int dcNr,
|
|||
extern void copy_used_cylinders(const struct dive *s, struct dive *d, bool used_only);
|
||||
extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx);
|
||||
extern struct event create_gas_switch_event(struct dive *dive, struct divecomputer *dc, int seconds, int idx);
|
||||
extern void per_cylinder_mean_depth(const struct dive *dive, struct divecomputer *dc, int *mean, int *duration);
|
||||
extern bool cylinder_with_sensor_sample(const struct dive *dive, int cylinder_id);
|
||||
|
||||
extern void update_setpoint_events(const struct dive *dive, struct divecomputer *dc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue