diff --git a/core/deco.cpp b/core/deco.cpp index 7cb550f12..c203ea934 100644 --- a/core/deco.cpp +++ b/core/deco.cpp @@ -13,8 +13,6 @@ * set_gf() - set Buehlmann gradient factors * set_vpmb_conservatism() - set VPM-B conservatism value * clear_deco() - * cache_deco_state() - * restore_deco_state() * dump_tissues() */ #include @@ -522,19 +520,17 @@ extern "C" void clear_deco(struct deco_state *ds, double surface_pressure, bool ds->ci_pointing_to_guiding_tissue = -1; } -extern "C" void cache_deco_state(struct deco_state *src, struct deco_state **cached_datap) +void deco_state_cache::cache(const struct deco_state *src) { - struct deco_state *data = *cached_datap; - - if (!data) { - data = (deco_state *)malloc(sizeof(struct deco_state)); - *cached_datap = data; - } + if (!data) + data = std::make_unique(); *data = *src; } -extern "C" void restore_deco_state(struct deco_state *data, struct deco_state *target, bool keep_vpmb_state) +void deco_state_cache::restore(struct deco_state *target, bool keep_vpmb_state) const { + if (!data) + return; if (keep_vpmb_state) { int ci; for (ci = 0; ci < 16; ci++) { @@ -547,7 +543,6 @@ extern "C" void restore_deco_state(struct deco_state *data, struct deco_state *t data->max_bottom_ceiling_pressure = target->max_bottom_ceiling_pressure; } *target = *data; - } extern "C" int deco_allowed_depth(double tissues_tolerance, double surface_pressure, const struct dive *dive, bool smooth) diff --git a/core/deco.h b/core/deco.h index cea87158e..f550aefe3 100644 --- a/core/deco.h +++ b/core/deco.h @@ -56,8 +56,6 @@ extern void clear_deco(struct deco_state *ds, double surface_pressure, bool in_p extern void dump_tissues(struct deco_state *ds); extern void set_gf(short gflow, short gfhigh); extern void set_vpmb_conservatism(short conservatism); -extern void cache_deco_state(struct deco_state *source, struct deco_state **datap); -extern void restore_deco_state(struct deco_state *data, struct deco_state *target, bool keep_vpmb_state); extern void nuclear_regeneration(struct deco_state *ds, double time); extern void vpmb_start_gradient(struct deco_state *ds); extern void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure, bool in_planner); @@ -74,6 +72,21 @@ extern void update_regression(struct deco_state *ds, const struct dive *dive); #ifdef __cplusplus } + +// C++ only functions + +#include +struct deco_state_cache { + // Test if there is cached data + operator bool () { + return !!data; + } + void cache(const struct deco_state *source); + void restore(struct deco_state *target, bool keep_vpmb_state) const; +private: + std::unique_ptr data; +}; + #endif #endif // DECO_H diff --git a/core/planner.cpp b/core/planner.cpp index 926d976b8..7b3105f44 100644 --- a/core/planner.cpp +++ b/core/planner.cpp @@ -111,7 +111,7 @@ static void interpolate_transition(struct deco_state *ds, struct dive *dive, dur } /* returns the tissue tolerance at the end of this (partial) dive */ -static int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_state **cached_datap) +static int tissue_at_end(struct deco_state *ds, struct dive *dive, deco_state_cache &cache) { struct divecomputer *dc; struct sample *sample, *psample; @@ -123,11 +123,11 @@ static int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_s if (!dive) return 0; - if (*cached_datap) { - restore_deco_state(*cached_datap, ds, true); + if (cache) { + cache.restore(ds, true); } else { surface_interval = init_decompression(ds, dive, true); - cache_deco_state(ds, cached_datap); + cache.cache(ds); } dc = &dive->dc; if (!dc->samples) @@ -544,12 +544,12 @@ static bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth, { bool clear_to_ascend = true; - struct deco_state *trial_cache = NULL; + deco_state_cache trial_cache; // For consistency with other VPM-B implementations, we should not start the ascent while the ceiling is // deeper than the next stop (thus the offgasing during the ascent is ignored). // However, we still need to make sure we don't break the ceiling due to on-gassing during ascent. - cache_deco_state(ds, &trial_cache); + trial_cache.cache(ds); if (wait_time) add_segment(ds, depth_to_bar(trial_depth, dive), gasmix, @@ -558,8 +558,7 @@ static bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth, double tolerance_limit = tissue_tolerance_calc(ds, dive, depth_to_bar(stoplevel, dive), true); update_regression(ds, dive); if (deco_allowed_depth(tolerance_limit, surface_pressure, dive, 1) > stoplevel) { - restore_deco_state(trial_cache, ds, false); - free(trial_cache); + trial_cache.restore(ds, false); return false; } } @@ -582,8 +581,7 @@ static bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth, } trial_depth -= deltad; } - restore_deco_state(trial_cache, ds, false); - free(trial_cache); + trial_cache.restore(ds, false); return clear_to_ascend; } @@ -654,7 +652,7 @@ static void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_de *avg_depth = *max_depth = 0; } -extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer) +bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, deco_state_cache &cache, bool is_planner, bool show_disclaimer) { int bottom_depth; @@ -663,7 +661,7 @@ extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct di bool is_final_plan = true; int bottom_time; int previous_deco_time; - struct deco_state *bottom_cache = NULL; + deco_state_cache bottom_cache; struct sample *sample; int po2; int transitiontime, gi; @@ -782,7 +780,7 @@ extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct di gi = gaschangenr - 1; /* Set tissue tolerance and initial vpmb gradient at start of ascent phase */ - diveplan->surface_interval = tissue_at_end(ds, dive, cached_datap); + diveplan->surface_interval = tissue_at_end(ds, dive, cache); nuclear_regeneration(ds, clock); vpmb_start_gradient(ds); if (decoMode(true) == RECREATIONAL) { @@ -850,7 +848,7 @@ extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct di } // VPM-B or Buehlmann Deco - tissue_at_end(ds, dive, cached_datap); + tissue_at_end(ds, dive, cache); if ((divemode == CCR || divemode == PSCR) && prefs.dobailout) { divemode = OC; po2 = 0; @@ -864,7 +862,7 @@ extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct di } previous_deco_time = 100000000; ds->deco_time = 10000000; - cache_deco_state(ds, &bottom_cache); // Lets us make several iterations + bottom_cache.cache(ds); // Lets us make several iterations bottom_depth = depth; bottom_gi = gi; bottom_gas = gas; @@ -878,7 +876,7 @@ extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct di vpmb_next_gradient(ds, ds->deco_time, diveplan->surface_pressure / 1000.0, true); previous_deco_time = ds->deco_time; - restore_deco_state(bottom_cache, ds, true); + bottom_cache.restore(ds, true); depth = bottom_depth; gi = bottom_gi; @@ -1124,7 +1122,6 @@ extern "C" bool plan(struct deco_state *ds, struct diveplan *diveplan, struct di free(stoplevels); free(gaschanges); - free(bottom_cache); return decodive; } diff --git a/core/planner.h b/core/planner.h index 127f51fa8..cf08fa152 100644 --- a/core/planner.h +++ b/core/planner.h @@ -36,6 +36,8 @@ struct diveplan { int surface_interval; }; +struct deco_state_cache; + #ifdef __cplusplus extern "C" { #endif @@ -58,9 +60,10 @@ struct decostop { int depth; int time; }; -extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer); #ifdef __cplusplus } + +extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, deco_state_cache &cache, bool is_planner, bool show_disclaimer); #endif #endif // PLANNER_H diff --git a/core/profile.cpp b/core/profile.cpp index b38eaca09..fb93245b2 100644 --- a/core/profile.cpp +++ b/core/profile.cpp @@ -943,11 +943,11 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_ ds->deco_time = planner_ds->deco_time; ds->first_ceiling_pressure = planner_ds->first_ceiling_pressure; } - struct deco_state *cache_data_initial = NULL; + deco_state_cache cache_data_initial; lock_planner(); /* For VPM-B outside the planner, cache the initial deco state for CVA iterations */ if (decoMode(in_planner) == VPMB) { - cache_deco_state(ds, &cache_data_initial); + cache_data_initial.cache(ds); } /* For VPM-B outside the planner, iterate until deco time converges (usually one or two iterations after the initial) * Set maximum number of iterations to 10 just in case */ @@ -1078,14 +1078,13 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_ last_ndl_tts_calc_time = entry->sec; /* We are going to mess up deco state, so store it for later restore */ - struct deco_state *cache_data = NULL; - cache_deco_state(ds, &cache_data); + deco_state_cache cache_data; + cache_data.cache(ds); calculate_ndl_tts(ds, dive, entry, gasmix, surface_pressure, current_divemode, in_planner); if (decoMode(in_planner) == VPMB && !in_planner && i == pi->nr - 1) final_tts = entry->tts_calc; /* Restore "real" deco state for next real time step */ - restore_deco_state(cache_data, ds, decoMode(in_planner) == VPMB); - free(cache_data); + cache_data.restore(ds, decoMode(in_planner) == VPMB); } } if (decoMode(in_planner) == VPMB && !in_planner) { @@ -1107,7 +1106,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_ first_iteration = false; count_iteration ++; this_deco_time = ds->deco_time; - restore_deco_state(cache_data_initial, ds, true); + cache_data_initial.restore(ds, true); ds->deco_time = this_deco_time; } else { // With Buhlmann iterating isn't needed. This makes the while condition false. @@ -1115,7 +1114,6 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_ } } - free(cache_data_initial); #if DECO_CALC_DEBUG & 1 dump_tissues(ds); #endif diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index cd29b3198..5c51a2de4 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -1073,12 +1073,12 @@ void DivePlannerPointsModel::updateDiveProfile() if (diveplan_empty(&diveplan)) return; - struct deco_state *cache = NULL; + deco_state_cache cache; struct decostop stoptable[60]; struct deco_state plan_deco_state; memset(&plan_deco_state, 0, sizeof(struct deco_state)); - plan(&plan_deco_state, &diveplan, d, DECOTIMESTEP, stoptable, &cache, isPlanner(), false); + plan(&plan_deco_state, &diveplan, d, DECOTIMESTEP, stoptable, cache, isPlanner(), false); updateMaxDepth(); if (isPlanner() && shouldComputeVariations()) { @@ -1103,8 +1103,6 @@ void DivePlannerPointsModel::updateDiveProfile() emit calculatedPlanNotes(QString(d->notes)); - // throw away the cache - free(cache); #if DEBUG_PLAN save_dive(stderr, d); dump_plan(&diveplan); @@ -1196,13 +1194,13 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, c struct dive *dive = alloc_dive(); copy_dive(d, dive); struct decostop original[60], deeper[60], shallower[60], shorter[60], longer[60]; - struct deco_state *cache = NULL, *save = NULL; + deco_state_cache cache, save; struct diveplan plan_copy; struct divedatapoint *last_segment; struct deco_state ds = *previous_ds; int my_instance = ++instanceCounter; - cache_deco_state(&ds, &save); + save.cache(&ds); duration_t delta_time = { .seconds = 60 }; QString time_units = tr("min"); @@ -1222,43 +1220,43 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, c goto finish; if (my_instance != instanceCounter) goto finish; - plan(&ds, &plan_copy, dive, 1, original, &cache, true, false); + plan(&ds, &plan_copy, dive, 1, original, cache, true, false); free_dps(&plan_copy); - restore_deco_state(save, &ds, false); + save.restore(&ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); last_segment->depth.mm += delta_depth.mm; last_segment->next->depth.mm += delta_depth.mm; if (my_instance != instanceCounter) goto finish; - plan(&ds, &plan_copy, dive, 1, deeper, &cache, true, false); + plan(&ds, &plan_copy, dive, 1, deeper, cache, true, false); free_dps(&plan_copy); - restore_deco_state(save, &ds, false); + save.restore(&ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); last_segment->depth.mm -= delta_depth.mm; last_segment->next->depth.mm -= delta_depth.mm; if (my_instance != instanceCounter) goto finish; - plan(&ds, &plan_copy, dive, 1, shallower, &cache, true, false); + plan(&ds, &plan_copy, dive, 1, shallower, cache, true, false); free_dps(&plan_copy); - restore_deco_state(save, &ds, false); + save.restore(&ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); last_segment->next->time += delta_time.seconds; if (my_instance != instanceCounter) goto finish; - plan(&ds, &plan_copy, dive, 1, longer, &cache, true, false); + plan(&ds, &plan_copy, dive, 1, longer, cache, true, false); free_dps(&plan_copy); - restore_deco_state(save, &ds, false); + save.restore(&ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); last_segment->next->time -= delta_time.seconds; if (my_instance != instanceCounter) goto finish; - plan(&ds, &plan_copy, dive, 1, shorter, &cache, true, false); + plan(&ds, &plan_copy, dive, 1, shorter, cache, true, false); free_dps(&plan_copy); - restore_deco_state(save, &ds, false); + save.restore(&ds, false); char buf[200]; sprintf(buf, ", %s: %c %d:%02d /%s %c %d:%02d /min", qPrintable(tr("Stop times")), @@ -1273,8 +1271,6 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, c finish: free_dps(original_plan); free(original_plan); - free(save); - free(cache); free_dive(dive); } @@ -1289,13 +1285,12 @@ void DivePlannerPointsModel::computeVariationsDone(QString variations) void DivePlannerPointsModel::createPlan(bool replanCopy) { // Ok, so, here the diveplan creates a dive - struct deco_state *cache = NULL; + deco_state_cache cache; removeDeco(); createTemporaryPlan(); - //TODO: C-based function here? struct decostop stoptable[60]; - plan(&ds_after_previous_dives, &diveplan, d, DECOTIMESTEP, stoptable, &cache, isPlanner(), true); + plan(&ds_after_previous_dives, &diveplan, d, DECOTIMESTEP, stoptable, cache, isPlanner(), true); if (shouldComputeVariations()) { struct diveplan *plan_copy; @@ -1306,8 +1301,6 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) computeVariations(plan_copy, &ds_after_previous_dives); } - free(cache); - // Fixup planner notes. if (current_dive && d->id == current_dive->id) { // Try to identify old planner output and remove only this part diff --git a/tests/testplan.cpp b/tests/testplan.cpp index b7c7ff57f..74448a1a1 100644 --- a/tests/testplan.cpp +++ b/tests/testplan.cpp @@ -15,7 +15,7 @@ static struct dive dive = { 0 }; static struct decostop stoptable[60]; static struct deco_state test_deco_state; -extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer); +extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, deco_state_cache &cache, bool is_planner, bool show_disclaimer); void setupPrefs() { copy_prefs(&default_prefs, &prefs); @@ -443,7 +443,7 @@ bool compareDecoTime(int actualRunTimeSeconds, int benchmarkRunTimeSeconds, int void TestPlan::testMetric() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefs(); prefs.unit_system = METRIC; @@ -453,7 +453,7 @@ void TestPlan::testMetric() struct diveplan testPlan = {}; setupPlan(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -484,7 +484,7 @@ void TestPlan::testMetric() void TestPlan::testImperial() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefs(); prefs.unit_system = IMPERIAL; @@ -494,7 +494,7 @@ void TestPlan::testImperial() struct diveplan testPlan = {}; setupPlan(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -525,7 +525,7 @@ void TestPlan::testImperial() void TestPlan::testVpmbMetric45m30minTx() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -534,7 +534,7 @@ void TestPlan::testVpmbMetric45m30minTx() struct diveplan testPlan = {}; setupPlanVpmb45m30mTx(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -555,7 +555,7 @@ void TestPlan::testVpmbMetric45m30minTx() void TestPlan::testVpmbMetric60m10minTx() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -564,7 +564,7 @@ void TestPlan::testVpmbMetric60m10minTx() struct diveplan testPlan = {}; setupPlanVpmb60m10mTx(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -585,7 +585,7 @@ void TestPlan::testVpmbMetric60m10minTx() void TestPlan::testVpmbMetric60m30minAir() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -594,7 +594,7 @@ void TestPlan::testVpmbMetric60m30minAir() struct diveplan testPlan = {}; setupPlanVpmb60m30minAir(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -615,7 +615,7 @@ void TestPlan::testVpmbMetric60m30minAir() void TestPlan::testVpmbMetric60m30minEan50() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -624,7 +624,7 @@ void TestPlan::testVpmbMetric60m30minEan50() struct diveplan testPlan = {}; setupPlanVpmb60m30minEan50(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -651,7 +651,7 @@ void TestPlan::testVpmbMetric60m30minEan50() void TestPlan::testVpmbMetric60m30minTx() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -660,7 +660,7 @@ void TestPlan::testVpmbMetric60m30minTx() struct diveplan testPlan = {}; setupPlanVpmb60m30minTx(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -687,7 +687,7 @@ void TestPlan::testVpmbMetric60m30minTx() void TestPlan::testVpmbMetric100m60min() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -696,7 +696,7 @@ void TestPlan::testVpmbMetric100m60min() struct diveplan testPlan = {}; setupPlanVpmb100m60min(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -729,7 +729,7 @@ void TestPlan::testVpmbMetric100m60min() void TestPlan::testMultipleGases() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -739,7 +739,7 @@ void TestPlan::testMultipleGases() setupPlanSeveralGases(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -755,7 +755,7 @@ void TestPlan::testMultipleGases() void TestPlan::testVpmbMetricMultiLevelAir() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -764,7 +764,7 @@ void TestPlan::testVpmbMetricMultiLevelAir() struct diveplan testPlan = {}; setupPlanVpmbMultiLevelAir(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -785,7 +785,7 @@ void TestPlan::testVpmbMetricMultiLevelAir() void TestPlan::testVpmbMetric100m10min() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -794,7 +794,7 @@ void TestPlan::testVpmbMetric100m10min() struct diveplan testPlan = {}; setupPlanVpmb100m10min(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -831,7 +831,7 @@ void TestPlan::testVpmbMetric100m10min() */ void TestPlan::testVpmbMetricRepeat() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefsVpmb(); prefs.unit_system = METRIC; @@ -840,7 +840,7 @@ void TestPlan::testVpmbMetricRepeat() struct diveplan testPlan = {}; setupPlanVpmb30m20min(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -861,7 +861,7 @@ void TestPlan::testVpmbMetricRepeat() int firstDiveRunTimeSeconds = dive.dc.duration.seconds; setupPlanVpmb100mTo70m30min(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -898,7 +898,7 @@ void TestPlan::testVpmbMetricRepeat() QVERIFY(compareDecoTime(dive.dc.duration.seconds, 127u * 60u + 20u, 127u * 60u + 20u)); setupPlanVpmb30m20min(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, 1, 0); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, 1, 0); #if DEBUG free(dive.notes); @@ -925,7 +925,7 @@ void TestPlan::testVpmbMetricRepeat() void TestPlan::testCcrBailoutGasSelection() { - struct deco_state *cache = NULL; + deco_state_cache cache; setupPrefs(); prefs.unit_system = METRIC; @@ -937,7 +937,7 @@ void TestPlan::testCcrBailoutGasSelection() struct diveplan testPlan = {}; setupPlanCcr(&testPlan); - plan(&test_deco_state, &testPlan, &dive, 60, stoptable, &cache, true, false); + plan(&test_deco_state, &testPlan, &dive, 60, stoptable, cache, true, false); #if DEBUG free(dive.notes);