summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/TabDiveInformation.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-27 07:42:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-09 19:19:04 +0100
commit11467fa326896934a299712810b74aef6a373c6f (patch)
treed8c599a8b2b5a50e4dd189ff8ec108cac20c007d /desktop-widgets/tab-widgets/TabDiveInformation.cpp
parentf179ec033f39a6b774e6e6bb79f41771dfaf7e02 (diff)
downloadsubsurface-11467fa326896934a299712810b74aef6a373c6f.tar.gz
Core: dynamically allocate the result of get_gas_used()
get_gas_used() returns the volume of used gases. Currently, an array with MAX_CYLINDERS is passed in. If we want to make the number of cylinders dynamic, the function must use an arbitrarilly sized array. Therefore, return a dynamically allocated array and free it in the caller. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveInformation.cpp')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveInformation.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
index 273bf4525..e6bb7c581 100644
--- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
@@ -53,8 +53,7 @@ void TabDiveInformation::updateProfile()
ui->maximumDepthText->setText(get_depth_string(current_dive->maxdepth, true));
ui->averageDepthText->setText(get_depth_string(current_dive->meandepth, true));
- volume_t gases[MAX_CYLINDERS] = {};
- get_gas_used(current_dive, gases);
+ volume_t *gases = get_gas_used(current_dive);
QString volumes;
int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS];
per_cylinder_mean_depth(current_dive, select_dc(current_dive), mean, duration);
@@ -76,6 +75,7 @@ void TabDiveInformation::updateProfile()
SACs.append(get_volume_string(sac, true).append(tr("/min")));
}
}
+ free(gases);
ui->gasUsedText->setText(volumes);
ui->oxygenHeliumText->setText(gaslist);