summaryrefslogtreecommitdiffstats
path: root/core/profile.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-07-06 17:18:43 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-09 19:19:04 +0100
commit00289cd2224bbf3bbb8568f52a73e52596bd8e6e (patch)
treef30bb4ee001773e885f14fbec340824ed05cd409 /core/profile.h
parentbef1eac7fa4baabc0f970b50acac1f4bee7d7f7c (diff)
downloadsubsurface-00289cd2224bbf3bbb8568f52a73e52596bd8e6e.tar.gz
Profile: dynamically allocate plot pressure data
All accesses to the pressure data were converted to use functions. Therefore it is now rather trivial to dynamically allocate the pressure array and just change the functions. The only thing to take care of is the idiosyncratic memory management. Make sure to free and copy the buffer in the appropriate places. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/profile.h')
-rw-r--r--core/profile.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/profile.h b/core/profile.h
index 0153ccf94..953cfdcc8 100644
--- a/core/profile.h
+++ b/core/profile.h
@@ -28,11 +28,16 @@ struct deco_state;
struct divecomputer;
struct plot_info;
+/*
+ * sensor data for a given cylinder
+ */
+struct plot_pressure_data {
+ int data[NUM_PLOT_PRESSURES];
+};
+
struct plot_data {
unsigned int in_deco : 1;
int sec;
- /* One pressure item per cylinder and pressure type */
- int pressure[MAX_CYLINDERS][NUM_PLOT_PRESSURES];
int temperature;
/* Depth info */
int depth;
@@ -104,12 +109,12 @@ extern int get_maxdepth(struct plot_info *pi);
static inline int get_plot_pressure_data(const struct plot_info *pi, int idx, enum plot_pressure sensor, int cylinder)
{
- return pi->entry[idx].pressure[cylinder][sensor];
+ return pi->pressures[cylinder * pi->nr + idx].data[sensor];
}
static inline void set_plot_pressure_data(struct plot_info *pi, int idx, enum plot_pressure sensor, int cylinder, int value)
{
- pi->entry[idx].pressure[cylinder][sensor] = value;
+ pi->pressures[cylinder * pi->nr + idx].data[sensor] = value;
}
static inline int get_plot_sensor_pressure(const struct plot_info *pi, int idx, int cylinder)