mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: return gasmix by value
Currently, get_gasmix_from_event() and get_gasmix() return pointers to either static or to (possibly changing) dive data. This seems like a dangerous practice and the returned data should be used immediately. Instead, return the gasmix by value. This is in preparation of const-ifying input parameters of a number of core functions, which will ultimately let the merge() function take const-arguments in preparation of undo of dive-merging. On common 64-bit systems gasmix (two "int"s) is the size of a pointer and can be returned in a register. On 32-bit systems a pointer to the struct to be filled out will be passed. Since get_gasmix() now returns a value, the first invocation is tested by a NULL-initialized "struct event *". Document this in a comment. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b6187f73aa
commit
f5b11daffd
10 changed files with 65 additions and 55 deletions
|
@ -759,7 +759,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
|
|||
eventItems.clear();
|
||||
struct event *event = currentdc->events;
|
||||
struct event *ev;
|
||||
struct gasmix lastgasmix = *get_gasmix(&displayed_dive, current_dc, 1, &ev, NULL);
|
||||
struct gasmix lastgasmix = get_gasmix(&displayed_dive, current_dc, 1, &ev, NULL);
|
||||
|
||||
while (event) {
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue