diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-08-16 19:10:10 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-23 05:16:38 -0700 |
commit | 360f07e4533d4ede7ba494724382fc8dbcb4649c (patch) | |
tree | 73a222ad3469e8a7fd085cb2671d12dac664aeac /core/divelist.c | |
parent | 5c4569247a31cf9f52238bd2b3f9c87b8f79933a (diff) | |
download | subsurface-360f07e4533d4ede7ba494724382fc8dbcb4649c.tar.gz |
Cleanup: pass gasmix by value
In a previous commit, the get_gasmix_* functions were changed to
return by value. For consistency, also pass gasmix by value.
Note that on common 64-bit platforms struct gasmix is the size
of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the
same space on the stack. On 32-bit platforms, the stack use
is probably doubled, but in return a dereference is avoided.
Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an
invasive change that going back to pointers is probably the
least of our worries.
This commit is a step in const-ifying input parameters (passing
by value is the ultimate way of signaling that the input parameter
will not be changed [unless there are references to said parameter]).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divelist.c')
-rw-r--r-- | core/divelist.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/divelist.c b/core/divelist.c index 12382d896..18e9b1ae3 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -94,8 +94,8 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2max_p) for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = dive->cylinder + i; - int o2 = get_o2(&cyl->gasmix); - int he = get_he(&cyl->gasmix); + int o2 = get_o2(cyl->gasmix); + int he = get_he(cyl->gasmix); if (!is_cylinder_used(dive, i)) continue; @@ -135,7 +135,7 @@ int total_weight(struct dive *dive) static int active_o2(struct dive *dive, struct divecomputer *dc, duration_t time) { struct gasmix gas = get_gasmix_at_time(dive, dc, time); - return get_o2(&gas); + return get_o2(gas); } /* calculate OTU for a dive - this only takes the first divecomputer into account */ @@ -420,8 +420,8 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive) for (j = t0; j < t1; j++) { int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0); - gasmix = get_gasmix(dive, dc, j, &ev, &gasmix); - add_segment(ds, depth_to_bar(depth, dive), &gasmix, 1, sample->setpoint.mbar, + gasmix = get_gasmix(dive, dc, j, &ev, gasmix); + add_segment(ds, depth_to_bar(depth, dive), gasmix, 1, sample->setpoint.mbar, get_current_divemode(&dive->dc, j, &evd, ¤t_divemode), dive->sac); } } @@ -576,7 +576,7 @@ int init_decompression(struct deco_state *ds, struct dive *dive) #endif return surface_time; } - add_segment(ds, surface_pressure, &air, surface_time, 0, dive->dc.divemode, prefs.decosac); + add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac); #if DECO_CALC_DEBUG & 2 printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60)); dump_tissues(ds); @@ -614,7 +614,7 @@ int init_decompression(struct deco_state *ds, struct dive *dive) #endif return surface_time; } - add_segment(ds, surface_pressure, &air, surface_time, 0, dive->dc.divemode, prefs.decosac); + add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac); #if DECO_CALC_DEBUG & 2 printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60)); dump_tissues(ds); |