diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-07-06 17:18:43 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-09 19:19:04 +0100 |
commit | 00289cd2224bbf3bbb8568f52a73e52596bd8e6e (patch) | |
tree | f30bb4ee001773e885f14fbec340824ed05cd409 /core/profile.c | |
parent | bef1eac7fa4baabc0f970b50acac1f4bee7d7f7c (diff) | |
download | subsurface-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.c')
-rw-r--r-- | core/profile.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/profile.c b/core/profile.c index 9fb2566bf..e27bcfd36 100644 --- a/core/profile.c +++ b/core/profile.c @@ -501,7 +501,6 @@ static void insert_entry(struct plot_info *pi, int idx, int time, int depth, int entry->sec = time; entry->depth = depth; entry->running_sum = prev->running_sum + (time - prev->sec) * (depth + prev->depth) / 2; - memset(entry->pressure, 0, sizeof(entry->pressure)); entry->sac = sac; entry->ndl = -1; entry->bearing = -1; @@ -510,6 +509,7 @@ static void insert_entry(struct plot_info *pi, int idx, int time, int depth, int void free_plot_info_data(struct plot_info *pi) { free(pi->entry); + free(pi->pressures); pi->entry = NULL; } @@ -534,6 +534,7 @@ static void populate_plot_entries(struct dive *dive, struct divecomputer *dc, st nr = dc->samples + 6 + maxtime / 10 + count_events(dc); plot_data = calloc(nr, sizeof(struct plot_data)); pi->entry = plot_data; + pi->pressures = calloc(nr * MAX_CYLINDERS, sizeof(struct plot_pressure_data)); if (!plot_data) return; pi->nr = nr; |