[PATCH 2/2] Planner: use pointer to deco stop level array instead of memcpy
Rick Walsh
rickmwalsh at gmail.com
Sat Jul 25 20:38:20 PDT 2015
Sorry, I left out the commit message. Patch attached.
On 26 July 2015 at 13:34, Rick Walsh <rickmwalsh at gmail.com> wrote:
> Signed-off-by: Rick Walsh <rickmwalsh at gmail.com>
> ---
> planner.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/planner.c b/planner.c
> index 550d463..bff329b 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--;
> --
> 2.4.3
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150726/e8186334/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Planner-use-pointer-to-deco-stop-level-array-instead.patch
Type: text/x-patch
Size: 2876 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150726/e8186334/attachment.bin>
More information about the subsurface
mailing list