IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18392


Ignore:
Timestamp:
Jun 30, 2008, 6:26:26 PM (18 years ago)
Author:
Paul Price
Message:

Plugging memory leak.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsImage.c

    r18208 r18392  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-06-20 02:50:01 $
     9 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2008-07-01 04:26:26 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    522522    int numRows = image->numRows;       // Number of rows for image
    523523    int status = 0;                     // Status from cfitsio
     524    bool success = true;
    524525    psFitsCompression *compress = NULL; // FITS compression parameters; to save state
    525526
     
    531532    if (!diskImage) {
    532533        psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format.");
    533         goto INSERT_FAIL;
     534        success = false;
     535        goto INSERT_DONE;
    534536    }
    535537
     
    537539    if (!isfinite(bscale) || !isfinite(bzero)) {
    538540        // Couldn't scale, so don't compress.  Save compression parameters for later
    539         useRequestedScale = false;
     541        useRequestedScale = false;
    540542        compress = psFitsCompressionGet(fits);
    541543        if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
    542544            psError(PS_ERR_IO, false, "Unable to unset compression.");
    543             goto INSERT_FAIL;
     545            success = false;
     546            goto INSERT_DONE;
    544547        }
    545548    }
     
    550553    int dataType;                       // cfitsio data type
    551554    if (!p_psFitsTypeToCfitsio(diskImage->type.type, &bitPix, &cfitsioBzero, &dataType)) {
    552         goto INSERT_FAIL;
     555        success = false;
     556        goto INSERT_DONE;
    553557    }
    554558    if (cfitsioBzero != 0.0) {
     
    592596    }
    593597    if (psFitsError(status, true, "Could not create image HDU.")) {
    594         goto INSERT_FAIL;
     598        success = false;
     599        goto INSERT_DONE;
    595600    }
    596601
     
    598603    if (header && !psFitsWriteHeader(fits, header)) {
    599604        psError(PS_ERR_IO, false, "Unable to write FITS header.\n");
    600         goto INSERT_FAIL;
     605        success = false;
     606        goto INSERT_DONE;
    601607    }
    602608
     
    612618                           "Scaling: TRUE = BZERO + BSCALE * DISK", &status);
    613619        if (psFitsError(status, true, "Could not write BSCALE/BZERO headers to file.")) {
    614             goto INSERT_FAIL;
     620            success = false;
     621            goto INSERT_DONE;
    615622        }
    616623    }
     
    624631        fits_set_imgnull(fits->fd, blank, &status);
    625632        if (psFitsError(status, true, "Could not write BLANK header to file.")) {
    626             goto INSERT_FAIL;
     633            success = false;
     634            goto INSERT_DONE;
    627635        }
    628636    }
     
    648656    }
    649657    if (psFitsError(status, true, "Could not write image to file.")) {
    650         goto INSERT_FAIL;
    651     }
    652 
    653     return true;
    654 
    655 INSERT_FAIL:
     658        success = false;
     659        goto INSERT_DONE;
     660    }
     661
     662 INSERT_DONE:
    656663    psFree(diskImage);
    657664    if (compress) {
     
    660667        psFree(compress);
    661668    }
    662     return false;
     669    return success;
    663670}
    664671
     
    699706    if (!isfinite(bscale) || !isfinite(bzero)) {
    700707        // Couldn't scale, so don't compress.  Save compression parameters for later
    701         useRequestedScale = false;
     708        useRequestedScale = false;
    702709        compress = psFitsCompressionGet(fits);
    703710        if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
Note: See TracChangeset for help on using the changeset viewer.