Commit d66df23115b41972acfd532ae40a3e7efc84f947

Authored by Jürgen Knödlseder
1 parent 9a86ee51

Properly free memory after usage to avoid memory leaks.

Showing 1 changed file with 8 additions and 5 deletions
test/test_GSky.cpp
... ... @@ -227,6 +227,9 @@ double TestGSky::wcs_copy(GWcslib* wcs, int nx, int ny, double& crpix1, double&
227 227 } // endfor: y pixels
228 228 } // endfor: x pixels
229 229  
  230 + // Delete copy
  231 + delete cpy;
  232 +
230 233 // Return
231 234 return ((dist_max > angle_max) ? dist_max : angle_max);
232 235 }
... ... @@ -280,7 +283,6 @@ void TestGSky::test_GWcslib(void)
280 283 try {
281 284 cel->set("CEL", crval1, crval2, crpix1, crpix2, cdelt1, cdelt2);
282 285 gal->set("GAL", crval1, crval2, crpix1, crpix2, cdelt1, cdelt2);
283   -
284 286 test_try_success();
285 287 }
286 288 catch (std::exception &e) {
... ... @@ -294,7 +296,6 @@ void TestGSky::test_GWcslib(void)
294 296 if ((tol = wcs_forth_back_pixel(cel, nx, ny, crpix1, crpix2)) > 1.0e-10) {
295 297 throw exception_failure("CEL forth-back transformation tolerance 1.0e-10 exceeded: "+gammalib::str(tol));
296 298 }
297   -
298 299 test_try_success();
299 300 }
300 301 catch (std::exception &e) {
... ... @@ -308,7 +309,6 @@ void TestGSky::test_GWcslib(void)
308 309 if ((tol = wcs_forth_back_pixel(gal, nx, ny, crpix1, crpix2)) > 1.0e-10) {
309 310 throw exception_failure("GAL forth-back transformation tolerance 1.0e-10 exceeded: "+gammalib::str(tol));
310 311 }
311   -
312 312 test_try_success();
313 313 }
314 314 catch (std::exception &e) {
... ... @@ -322,7 +322,6 @@ void TestGSky::test_GWcslib(void)
322 322 if ((tol = wcs_copy(cel, nx, ny, crpix1, crpix2)) > 1.0e-4) {
323 323 throw exception_failure("CEL copy tolerance 1.0e-4 exceeded: "+gammalib::str(tol));
324 324 }
325   -
326 325 test_try_success();
327 326 }
328 327 catch (std::exception &e) {
... ... @@ -336,13 +335,17 @@ void TestGSky::test_GWcslib(void)
336 335 if ((tol = wcs_copy(gal, nx, ny, crpix1, crpix2)) > 1.0e-4) {
337 336 throw exception_failure("GAL copy tolerance 1.0e-4 exceeded: "+gammalib::str(tol));
338 337 }
339   -
340 338 test_try_success();
341 339 }
342 340 catch (std::exception &e) {
343 341 test_try_failure(e);
344 342 }
345 343  
  344 + // Free memory
  345 + delete cel;
  346 + delete gal;
  347 +
  348 + // Signal success
346 349 test_try_success();
347 350 }
348 351 catch (std::exception &e) {
... ...