summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2015-07-26 13:34:43 +1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-26 09:14:06 -0700
commit1885eccc4911e8a634bb2c1cc89500429d5cfc0f (patch)
treeebb0037b057f86241143bb28387bbe90fea7de06 /planner.c
parent036e992d14420c3db75d050b39d0d113b35b9aec (diff)
downloadsubsurface-1885eccc4911e8a634bb2c1cc89500429d5cfc0f.tar.gz
Planner: use pointer to deco stop level array instead of memcpy
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r--planner.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/planner.c b/planner.c
index 550d46362..bff329bd3 100644
--- a/planner.c
+++ b/planner.c
@@ -29,7 +29,6 @@ int decostoplevels_imperial[] = { 0, 3048, 6096, 9144, 12192, 15240, 18288, 2133
91440, 101600, 111760, 121920, 132080, 142240, 152400, 162560, 172720,
182880, 193040, 203200, 223520, 243840, 264160, 284480, 304800,
325120, 345440, 365760, 386080 };
-int decostoplevels[sizeof(decostoplevels_metric) / sizeof(int)];
double plangflow, plangfhigh;
bool plan_verbatim, plan_display_runtime, plan_display_duration, plan_display_transitions;
@@ -885,6 +884,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
double tissue_tolerance = 0.0;
struct gaschanges *gaschanges = NULL;
int gaschangenr;
+ int *decostoplevels;
+ int decostoplevelcount;
unsigned int *stoplevels = NULL;
bool stopping = false;
bool pendinggaschange = false;
@@ -906,13 +907,17 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
create_dive_from_plan(diveplan, is_planner);
if (prefs.units.length == METERS ) {
- memcpy(decostoplevels, decostoplevels_metric, sizeof(decostoplevels_metric));
+ decostoplevels = decostoplevels_metric;
+ decostoplevelcount = sizeof(decostoplevels_metric) / sizeof(int);
} else {
- memcpy(decostoplevels, decostoplevels_imperial, sizeof(decostoplevels_imperial));
+ decostoplevels = decostoplevels_imperial;
+ decostoplevelcount = sizeof(decostoplevels_imperial) / sizeof(int);
}
if (prefs.last_stop)
- decostoplevels[1] = 0;
+ *(decostoplevels + 1) = 0;
+ else
+ *(decostoplevels + 1) = M_OR_FT(3,10);
/* Let's start at the last 'sample', i.e. the last manually entered waypoint. */
sample = &displayed_dive.dc.sample[displayed_dive.dc.samples - 1];
@@ -952,8 +957,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
gaschanges = analyze_gaslist(diveplan, &gaschangenr, depth, &best_first_ascend_cylinder);
}
/* Find the first potential decostopdepth above current depth */
- for (stopidx = 0; stopidx < sizeof(decostoplevels) / sizeof(int); stopidx++)
- if (decostoplevels[stopidx] >= depth)
+ for (stopidx = 0; stopidx < decostoplevelcount; stopidx++)
+ if (*(decostoplevels + stopidx) >= depth)
break;
if (stopidx > 0)
stopidx--;