IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 3, 2021, 3:05:40 PM (5 years ago)
Author:
eugene
Message:

plug various leaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpLoopBackground.c

    r40354 r41510  
    5555    if (!status) {
    5656        psError(PSWARP_ERR_DATA, true, "number of inputs is not defined (programming error)");
     57        psFree (view);
    5758        return false;
    5859    }
     
    9091        pmFPAviewReset (view);
    9192
    92         pmFPAview *view = pmFPAviewAlloc(0);
    93         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     93        pmFPAview *viewT2 = pmFPAviewAlloc(0);
     94        if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_BEFORE)) {
    9495            psError(psErrorCodeLast(), false, "Unable to read files.");
     96            psFree (viewT2);
    9597            goto FAIL;
    9698        }
    9799
    98100        pmChip *chip;
    99         while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     101        while ((chip = pmFPAviewNextChip (viewT2, input->fpa, 1)) != NULL) {
    100102            if (!chip->process || !chip->file_exists) { continue; }
    101             if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     103            if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_BEFORE)) {
    102104                psError(psErrorCodeLast(), false, "Unable to read files.");
     105                psFree (viewT2);
    103106                goto FAIL;
    104107            }
     
    107110            double xBin = NAN;
    108111            double yBin = NAN;
    109             pswarpGetInputScales (&xBin, &yBin, config, view, chip);
     112            pswarpGetInputScales (&xBin, &yBin, config, viewT2, chip);
    110113            double fluxRatio = xBin * yBin / (float) (xGrid * yGrid);
    111114           
    112             if (!pswarpModifyChipAstrom (config, view, chip, astrom, bilevelAstrometry, xBin, yBin)) {
     115            if (!pswarpModifyChipAstrom (config, viewT2, chip, astrom, bilevelAstrometry, xBin, yBin)) {
    113116                psError(psErrorCodeLast(), false, "failed to set BKGMODEL astrometry.");
     117                psFree (viewT2);
    114118                goto FAIL;
    115119            }
    116120
    117121            pmCell *cell;
    118             while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    119                 psTrace ("pswarp", 4, "ACell %d: %x %x %d\n", view->cell, cell->file_exists, cell->process,psErrorCodeLast());
     122            while ((cell = pmFPAviewNextCell (viewT2, input->fpa, 1)) != NULL) {
     123                psTrace ("pswarp", 4, "ACell %d: %x %x %d\n", viewT2->cell, cell->file_exists, cell->process,psErrorCodeLast());
    120124                if (!cell->process || !cell->file_exists) { continue; }
    121                 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     125                if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_BEFORE)) {
    122126                    psError(psErrorCodeLast(), false, "Unable to read files.");
     127                    psFree (viewT2);
    123128                    goto FAIL;
    124129                }
     
    126131                // process each of the readouts
    127132                pmReadout *readout;
    128                 while ((readout = pmFPAviewNextReadout(view, input->fpa, 1)) != NULL) {
    129                     if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     133                while ((readout = pmFPAviewNextReadout(viewT2, input->fpa, 1)) != NULL) {
     134                    if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_BEFORE)) {
    130135                        psError(psErrorCodeLast(), false, "Unable to read files.");
     136                        psFree (viewT2);
    131137                        goto FAIL;
    132138                    }
     
    136142
    137143                    if (astrom != input) {
    138                       pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry
    139                       if ((!refcat)&&(astromRO)) {
    140                         if ((astromRO->parent->parent->hdu->header)&&(output->fpa->analysis)) {
    141                           psMetadataItem *refItem = psMetadataLookup(astromRO->parent->parent->hdu->header, "PSREFCAT");
    142                           if (refItem) {
    143                             refcat = psMetadataLookupStr(NULL, astromRO->parent->parent->hdu->header, "PSREFCAT");
    144                             psMetadataAddStr(output->fpa->analysis, PS_LIST_TAIL, "REFERENCE_CATALOG", PS_META_REPLACE,
    145                                              "Reference catalog used for calibration.", refcat);
    146                           }
     144                        pmReadout *astromRO = pmFPAviewThisReadout(viewT2, astrom->fpa); // Readout for astrometry
     145                        if ((!refcat)&&(astromRO)) {
     146                            if ((astromRO->parent->parent->hdu->header)&&(output->fpa->analysis)) {
     147                                psMetadataItem *refItem = psMetadataLookup(astromRO->parent->parent->hdu->header, "PSREFCAT");
     148                                if (refItem) {
     149                                    refcat = psMetadataLookupStr(NULL, astromRO->parent->parent->hdu->header, "PSREFCAT");
     150                                    psMetadataAddStr(output->fpa->analysis, PS_LIST_TAIL, "REFERENCE_CATALOG", PS_META_REPLACE,
     151                                                     "Reference catalog used for calibration.", refcat);
     152                                }
     153                            }
    147154                        }
    148                       }
    149155                    }
    150156                   
     
    159165                    pswarpTransformToTarget (output->fpa, readout, config, true);
    160166
    161                     if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { // Readout
     167                    if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // Readout
    162168                        psError(psErrorCodeLast(), false, "Unable to close files.");
     169                        psFree (viewT2);
    163170                        goto FAIL;
    164171                    }
    165172                }
    166173
    167                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { // Cell
     174                if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // Cell
    168175                    psError(psErrorCodeLast(), false, "Unable to close files.");
     176                    psFree (viewT2);
    169177                    goto FAIL;
    170178                }
    171179            }
    172180
    173             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { // Chip
     181            if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // Chip
    174182                psError(psErrorCodeLast(), false, "Unable to close files.");
     183                psFree (viewT2);
    175184                goto FAIL;
    176185            }
    177186        }
    178187
    179         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { // FPA
     188        if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // FPA
    180189            psError(psErrorCodeLast(), false, "Unable to close files.");
     190            psFree (viewT2);
    181191            goto FAIL;
    182192        }
     
    184194        if (!pswarpUpdateMetadata (output->fpa, skycell->fpa, input->fpa, astrom->fpa, config, false)) {
    185195            psError(psErrorCodeLast(), false, "problem generating statistics.");
     196            psFree (viewT2);
    186197            goto FAIL;
    187198        }
     199        psFree (viewT2);
    188200    }
    189201
Note: See TracChangeset for help on using the changeset viewer.