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 /qt-models/diveplotdatamodel.cpp | |
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 'qt-models/diveplotdatamodel.cpp')
-rw-r--r-- | qt-models/diveplotdatamodel.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/qt-models/diveplotdatamodel.cpp b/qt-models/diveplotdatamodel.cpp index c8f086867..d89ab6f31 100644 --- a/qt-models/diveplotdatamodel.cpp +++ b/qt-models/diveplotdatamodel.cpp @@ -167,7 +167,9 @@ void DivePlotDataModel::clear() beginResetModel(); pInfo.nr = 0; free(pInfo.entry); - pInfo.entry = 0; + free(pInfo.pressures); + pInfo.entry = nullptr; + pInfo.pressures = nullptr; diveId = -1; dcNr = -1; endResetModel(); @@ -179,9 +181,12 @@ void DivePlotDataModel::setDive(dive *d, const plot_info &info) diveId = d->id; dcNr = dc_number; free(pInfo.entry); + free(pInfo.pressures); pInfo = info; - pInfo.entry = (struct plot_data *)malloc(sizeof(struct plot_data) * pInfo.nr); + pInfo.entry = (plot_data *)malloc(sizeof(plot_data) * pInfo.nr); memcpy(pInfo.entry, info.entry, sizeof(plot_data) * pInfo.nr); + pInfo.pressures = (plot_pressure_data *)malloc(sizeof(plot_pressure_data) * MAX_CYLINDERS * pInfo.nr); + memcpy(pInfo.pressures, info.pressures, sizeof(plot_pressure_data) * MAX_CYLINDERS * pInfo.nr); endResetModel(); } |