Browse Source

sparse engine: consistently use delete[] when destroying solution vectors

Technically, using 'plain' delete for deleting objects allocated with new[] is
undefined behaviour. In practice, this didn't appear to be a problem.


git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11786 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 10 years ago
parent
commit
9850ae3c71
  1. 2
      prism/src/sparse/PS_JOR.cc
  2. 2
      prism/src/sparse/PS_NondetReachReward.cc
  3. 2
      prism/src/sparse/PS_NondetUntil.cc
  4. 2
      prism/src/sparse/PS_Power.cc
  5. 2
      prism/src/sparse/PS_SOR.cc

2
prism/src/sparse/PS_JOR.cc

@ -300,7 +300,7 @@ jdouble omega // omega (over-relaxation parameter)
PS_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup);
// if the iterative method didn't terminate, this is an error
if (!done) { delete soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
// catch exceptions: register error, free memory
} catch (std::bad_alloc e) {

2
prism/src/sparse/PS_NondetReachReward.cc

@ -387,7 +387,7 @@ jboolean min // min or max probabilities (true = min, false = max)
PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup);
// if the iterative method didn't terminate, this is an error
if (!done) { delete soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
// close file to store adversary (if required)
if (export_adv_enabled != EXPORT_ADV_NONE) {

2
prism/src/sparse/PS_NondetUntil.cc

@ -347,7 +347,7 @@ jlong _strat // strategy storage
PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup);
// if the iterative method didn't terminate, this is an error
if (!done) { delete soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
// close file to store adversary (if required)
if (export_adv_enabled != EXPORT_ADV_NONE) {

2
prism/src/sparse/PS_Power.cc

@ -246,7 +246,7 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?)
PS_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup);
// if the iterative method didn't terminate, this is an error
if (!done) { delete soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
// catch exceptions: register error, free memory
} catch (std::bad_alloc e) {

2
prism/src/sparse/PS_SOR.cc

@ -301,7 +301,7 @@ jboolean forwards // forwards or backwards?
PS_PrintToMainLog(env, "\n%s%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup);
// if the iterative method didn't terminate, this is an error
if (!done) { delete soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); }
// catch exceptions: register error, free memory
} catch (std::bad_alloc e) {

Loading…
Cancel
Save