MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / CleanMemoryUsage

Method CleanMemoryUsage

engine/source/graphics/PNGImage.cpp:413–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413bool PNGImage::CleanMemoryUsage()
414{
415 if(mRead == true && mWrite == true)
416 return false;
417
418 if(mRead == true)
419 {
420 if(mPng != NULL && mInfo != NULL)
421 {
422 png_destroy_read_struct(&mPng, &mInfo, NULL);
423 mPng = NULL;
424 mInfo = NULL;
425 }
426 else
427 {
428 if(mPng != NULL)
429 {
430 png_destroy_read_struct(&mPng, NULL, NULL);
431 mPng = NULL;
432 }
433 else if(mInfo != NULL)
434 {
435 png_read_info(mPng, mInfo);
436 mInfo = NULL;
437 }
438 }
439
440 for (unsigned int y = 0; y < mHeight; y++)
441 dFree(mRowPointers[y]);
442
443 dFree(mRowPointers);
444 mRowPointers= NULL;
445 }
446 else if(mWrite == true)
447 {
448 if(mPng != NULL && mInfo != NULL)
449 {
450 png_destroy_write_struct(&mPng, &mInfo);
451 mPng = NULL;
452 mInfo = NULL;
453 }
454 else
455 {
456 if(mPng != NULL)
457 {
458 png_destroy_write_struct(&mPng, NULL);
459 mPng = NULL;
460 }
461
462 if(mInfo != NULL)
463 {
464 png_read_info(mPng, mInfo);
465 mInfo = NULL;
466 }
467 }
468 for (unsigned int y = 0; y < mHeight; y++)
469 dFree(mRowPointers[y]);
470

Callers 1

Calls 4

png_destroy_read_structFunction · 0.85
png_read_infoFunction · 0.85
dFreeFunction · 0.85
png_destroy_write_structFunction · 0.85

Tested by

no test coverage detected