Mercurial > public > ostc4
changeset 254:a17f7fb3b2b5 bm-3
Buehlmann: cleanup, remove global pDecolistBuehlmann
Yes, I hate global data, and a simple renaming of a pointer almost
qualifies for participation in the Obfuscated C Code Contest :-)
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Fri, 12 Apr 2019 14:46:48 +0200 |
parents | 1663b3b204d7 |
children | dcf7a3435fe1 |
files | Discovery/Src/buehlmann.c |
diffstat | 1 files changed, 9 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/buehlmann.c Fri Apr 12 10:43:52 2019 +0200 +++ b/Discovery/Src/buehlmann.c Fri Apr 12 14:46:48 2019 +0200 @@ -56,7 +56,6 @@ static int gNDL; SDiveSettings *pBuDiveSettings; -SDecoinfo* pDecolistBuehlmann; float gGF_low_depth_bar; SStop gStop; @@ -127,7 +126,6 @@ /* make input available global*/ pBuDiveSettings = pDiveSettings; - pDecolistBuehlmann = pDecoInfo; /* internal copying */ gSurface_pressure_bar = pLifeData->pressure_surface_bar; @@ -138,7 +136,7 @@ gGF_value = ((float)pBuDiveSettings->gf_low) / 100.0f; // - memcpy(&gDecotable, pDecolistBuehlmann, sizeof(SDecoinfo)); + memcpy(&gDecotable, pDecoInfo, sizeof(SDecoinfo)); stoplist = gDecotable.output_stop_length_seconds; if(pLifeData->dive_time_seconds < 60) @@ -161,16 +159,16 @@ { buehlmann_backup_and_restore(false); // no deco - pDecolistBuehlmann->output_time_to_surface_seconds = 0; + pDecoInfo->output_time_to_surface_seconds = 0; for(i = 0; i < DECOINFO_STRUCT_MAX_STOPS; i++) - pDecolistBuehlmann->output_stop_length_seconds[i] = 0; + pDecoInfo->output_stop_length_seconds[i] = 0; // calc NDL buehlmann_calc_ndl(); - pDecolistBuehlmann->output_ndl_seconds = gNDL; + pDecoInfo->output_ndl_seconds = gNDL; return; } buehlmann_backup_and_restore(false); - pDecolistBuehlmann->output_ndl_seconds = 0; + pDecoInfo->output_ndl_seconds = 0; gGF_value = get_gf_at_pressure(gPressure); //current ceiling at actual position @@ -192,8 +190,7 @@ ceiling = tissue_tolerance(); if(tts_seconds > DECO_STOPS_MAX_TTS_CALCULATON_IN_SECONDS) { - /* pInput == pBuehlmann */ - pDecolistBuehlmann->output_time_to_surface_seconds = NINETY_NINE_MINUTES_IN_SECONDS; + pDecoInfo->output_time_to_surface_seconds = NINETY_NINE_MINUTES_IN_SECONDS; return;// NINETY_NINE_MINUTES_IN_SECONDS; } } while ((ascend_time > 0 ) && ((gPressure - PRESSURE_TEN_METER ) > gSurface_pressure_bar) && (ceiling < (gPressure - PRESSURE_TEN_METER))); @@ -205,8 +202,7 @@ ceiling = tissue_tolerance(); if(tts_seconds > DECO_STOPS_MAX_TTS_CALCULATON_IN_SECONDS) { - /* pInput == pBuehlmann */ - pDecolistBuehlmann->output_time_to_surface_seconds = NINETY_NINE_MINUTES_IN_SECONDS; + pDecoInfo->output_time_to_surface_seconds = NINETY_NINE_MINUTES_IN_SECONDS; return;// NINETY_NINE_MINUTES_IN_SECONDS; } ambient_bar_to_deco_stop_depth_bar(ceiling); @@ -237,9 +233,8 @@ // NDL check if(ceiling <= gSurface_pressure_bar) { - /* pInput == pBuehlmann same pointer*/ // NDL with GF_low - pDecolistBuehlmann->output_time_to_surface_seconds = 0; + pDecoInfo->output_time_to_surface_seconds = 0; return; } if (ceiling > pDiveSettings->internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero) @@ -298,7 +293,7 @@ } gDecotable.output_time_to_surface_seconds = tts_seconds; - memcpy(pDecolistBuehlmann, &gDecotable, sizeof(SDecoinfo)); + memcpy(pDecoInfo, &gDecotable, sizeof(SDecoinfo)); }