diff Discovery/Src/buehlmann.c @ 258:0087d6251f59 bm-3

Buehlmann: factor out another global gDecotable And strip out another useless global. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Fri, 12 Apr 2019 22:00:07 +0200
parents 21387d7e786f
children cc2406b835ff
line wrap: on
line diff
--- a/Discovery/Src/buehlmann.c	Fri Apr 12 21:04:52 2019 +0200
+++ b/Discovery/Src/buehlmann.c	Fri Apr 12 22:00:07 2019 +0200
@@ -43,7 +43,6 @@
 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings);
 static _Bool dive1_check_deco(SDiveSettings *pDiveSettings);
 
-static SDecoinfo gDecotable;
 static float gSurface_pressure_bar;
 static float gPressure;
 static int gGas_id;
@@ -122,9 +121,7 @@
 	memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16));
 	gGF_value = ((float)pDiveSettings->gf_low) / 100.0f;
 	
-	//
-	memcpy(&gDecotable, pDecoInfo, sizeof(SDecoinfo));
-	stoplist = gDecotable.output_stop_length_seconds;
+	stoplist = pDecoInfo->output_stop_length_seconds;
 
 	if(pLifeData->dive_time_seconds < 60)
 		return;
@@ -240,10 +237,10 @@
 			ascend_time = ascend_with_all_gaschanges(pDiveSettings, gStop.depth - next_depth);
 			ceiling = tissue_tolerance();
 			/* pre check actual limit */
-			if(gDecotable.output_stop_length_seconds[gStop.id] >= 999*60)
+			if(pDecoInfo->output_stop_length_seconds[gStop.id] >= 999*60)
 			{
-				tts_seconds -= 999*60 - gDecotable.output_stop_length_seconds[gStop.id];
-				gDecotable.output_stop_length_seconds[gStop.id] = 999*60;
+				tts_seconds -= 999*60 - pDecoInfo->output_stop_length_seconds[gStop.id];
+				pDecoInfo->output_stop_length_seconds[gStop.id] = 999*60;
 			}
 			else
 			/* more deco on the actual depth */
@@ -253,7 +250,7 @@
 				buehlmann_backup_and_restore(false);
 				decom_tissues_exposure2(10, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar); // some seconds at least at each stop
 				decom_oxygen_calculate_cns_exposure(10, &pDiveSettings->decogaslist[gGas_id], gPressure, &gCNS);
-        gDecotable.output_stop_length_seconds[gStop.id] += 10;
+				pDecoInfo->output_stop_length_seconds[gStop.id] += 10;
         tts_seconds += 10;
 			}
 		} while(next_depth == -1);
@@ -276,8 +273,7 @@
 		gStop.id--;
 	}
 
-	gDecotable.output_time_to_surface_seconds = tts_seconds;
-	memcpy(pDecoInfo, &gDecotable, sizeof(SDecoinfo));
+	pDecoInfo->output_time_to_surface_seconds = tts_seconds;
 }