aboutsummaryrefslogtreecommitdiffstats
path: root/core/save-xml.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-16 13:35:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-23 05:16:38 -0700
commitf5b11daffd6f240268ce78d72c64be43670988ea (patch)
tree99805cc176483e5f069a7920c11528e37cf0db8c /core/save-xml.c
parentb6187f73aad09adb0b70af8d77f1af1a34a338f8 (diff)
downloadsubsurface-f5b11daffd6f240268ce78d72c64be43670988ea.tar.gz
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>
Diffstat (limited to 'core/save-xml.c')
-rw-r--r--core/save-xml.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/save-xml.c b/core/save-xml.c
index e3af000a4..7e2328e5c 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -307,10 +307,10 @@ static void save_one_event(struct membuffer *b, struct dive *dive, struct event
show_index(b, ev->value, "value='", "'");
show_utf8(b, ev->name, " name='", "'", 1);
if (event_is_gaschange(ev)) {
- struct gasmix *mix = get_gasmix_from_event(dive, ev);
+ struct gasmix mix = get_gasmix_from_event(dive, ev);
if (ev->gas.index >= 0)
show_integer(b, ev->gas.index, "cylinder='", "'");
- put_gasmix(b, mix);
+ put_gasmix(b, &mix);
}
put_format(b, " />\n");
}