IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6743


Ignore:
Timestamp:
Mar 30, 2006, 3:33:07 PM (20 years ago)
Author:
Paul Price
Message:

Plugging memory leaks --- done.

Location:
branches/rel10_ifa/psModules/src/astrom
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmChipMosaic.c

    r6448 r6743  
    358358        }
    359359
    360         numChips++;
    361         pmChipMosaic(chip, xBinChip, yBinChip); // Mosaic of cells within the chip
    362 
     360        if (pmChipMosaic(chip, xBinChip, yBinChip) > 0) {
     361            numChips++;
     362        }
    363363    }
    364364
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsStandard.c

    r6734 r6743  
    489489
    490490    // Otherwise, there's no formatting required
    491     return concept;
     491    return psMemIncrRefCounter(concept);
    492492}
    493493
     
    508508
    509509    // No formatting required
    510     return concept;
     510    return psMemIncrRefCounter(concept);
    511511}
    512512
     
    561561        if (strstr(format, "PRE2000")) {
    562562            psError(PS_ERR_IO, true, "Don't you realise it's the twenty-first century?\n");
    563             return false;
     563            return NULL;
    564564        }
    565565        if (strstr(format, "BACKWARDS")) {
    566566            psError(PS_ERR_IO, true, "You want it BACKWARDS?  Not right now, thanks.\n");
    567             return false;
     567            return NULL;
    568568        }
    569569
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsWrite.c

    r6734 r6743  
    204204                        psTrace(__func__, 8, "Writing %s to header %s\n", name, cameraItem->data.V);
    205205                        writeHeader(hdu, cameraItem->data.V, formatted);
    206                         continue;
    207                     }
    208                     if (strcasecmp(source, "VALUE") == 0) {
     206                    } else if (strcasecmp(source, "VALUE") == 0) {
    209207                        psTrace(__func__, 8, "Checking %s against camera format.\n", name);
    210208                        if (! compareConcepts(cameraItem, formatted)) {
     
    212210                                     "format, but the values don't match.\n", name);
    213211                        }
    214                         continue;
     212                    } else {
     213                        psLogMsg(__func__, PS_LOG_WARN, "Concept source %s isn't HEADER or VALUE --- can't "
     214                                 "write\n", nameSource);
    215215                    }
    216                     psLogMsg(__func__, PS_LOG_WARN, "Concept source %s isn't HEADER or VALUE --- can't "
    217                              "write\n", nameSource);
    218                     continue;
    219                 }
    220                 // Assume it's specified by value
    221                 if (! compareConcepts(cameraItem, formatted)) {
     216                } else if (! compareConcepts(cameraItem, formatted)) {
     217                    // Assume it's specified by value
    222218                    psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
    223219                             "format, but the values don't match.\n", name);
    224220                }
     221                psFree(formatted);
     222                psFree(nameSource);
    225223            }
    226224
     
    232230}
    233231
    234 
     232// XXX: Needs the .DEPEND stuff
    235233bool pmConceptsWriteToDefaults(psMetadata *specs, // The concept specifications
    236234                               pmFPA *fpa, // The FPA
     
    266264                             "format, but the values don't match.\n");
    267265                }
     266                psFree(formatted);
    268267            }
    269268        }
     
    331330                    writeHeader(hdu, keyword, formatted);
    332331                }
     332                psFree(formatted);
     333                psFree(keywords);
    333334            }
    334335        }
  • branches/rel10_ifa/psModules/src/astrom/pmFPA.c

    r6713 r6743  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.1.4.5 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-03-28 02:16:26 $
     14*  @version $Revision: 1.1.4.6 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-03-31 01:33:07 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3838static void readoutFree(pmReadout *readout)
    3939{
    40     if (readout != NULL) {
    41         psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t) readout->parent);
    42         if (readout->parent) {
    43             psArray *readouts = readout->parent->readouts;
    44             for (int i = 0; i < readouts->n; i++) {
    45                 if (readouts->data[i] == readout) {
    46                     //                    pmReadout *tmpReadout = readouts->data[i];
    47                     readouts->data[i] = NULL;
    48                     #if PARENT_LINKS
    49 
    50                     psFree(tmpReadout);
    51                     #endif
    52 
    53                     break;
    54                 }
     40    psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t) readout->parent);
     41    if (readout->parent) {
     42        psArray *readouts = readout->parent->readouts;
     43        for (int i = 0; i < readouts->n; i++) {
     44            if (readouts->data[i] == readout) {
     45                //                    pmReadout *tmpReadout = readouts->data[i];
     46                readouts->data[i] = NULL;
     47                #if PARENT_LINKS
     48
     49                psFree(tmpReadout);
     50                #endif
     51
     52                break;
    5553            }
    5654        }
    57         psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout);
    58 
    59         #if PARENT_LINKS
    60 
    61         psFree(readout->parent);
    62         #endif
    63 
    64         psFree(readout->image);
    65         psFree(readout->mask);
    66         psFree(readout->weight);
    67         psFree(readout->analysis);
    68         psFree(readout->bias);
    69     }
     55    }
     56    psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout);
     57
     58    #if PARENT_LINKS
     59
     60    psFree(readout->parent);
     61    #endif
     62
     63    psFree(readout->image);
     64    psFree(readout->mask);
     65    psFree(readout->weight);
     66    psFree(readout->analysis);
     67    psFree(readout->bias);
    7068}
    7169
    7270static void cellFree(pmCell *cell)
    7371{
    74     if (cell != NULL) {
    75         psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent);
    76         if (cell->parent) {
    77             psArray *cells = cell->parent->cells;
    78             for (int i = 0; i < cells->n; i++) {
    79                 if (cells->data[i] == cell) {
    80                     //                    pmCell *tmpCell = cells->data[i];
    81                     cells->data[i] = NULL;
    82                     #if PARENT_LINKS
    83 
    84                     psFree(tmpCell);
    85                     #endif
    86 
    87                     break;
    88                 }
     72    psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent);
     73    if (cell->parent) {
     74        psArray *cells = cell->parent->cells;
     75        for (int i = 0; i < cells->n; i++) {
     76            if (cells->data[i] == cell) {
     77                //                    pmCell *tmpCell = cells->data[i];
     78                cells->data[i] = NULL;
     79                #if PARENT_LINKS
     80
     81                psFree(tmpCell);
     82                #endif
     83
     84                break;
    8985            }
    9086        }
    91         psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell);
    92 
    93         pmCellFreeReadouts(cell);
    94         psFree(cell->readouts);
    95         #if PARENT_LINKS
    96 
    97         psFree(cell->parent);
    98         #endif
    99 
    100         psFree(cell->concepts);
    101         psFree(cell->analysis);
    102         psFree(cell->config);
    103         psFree(cell->hdu);
    104     }
     87    }
     88    psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell);
     89
     90    pmCellFreeReadouts(cell);
     91    psFree(cell->readouts);
     92    #if PARENT_LINKS
     93
     94    psFree(cell->parent);
     95    #endif
     96
     97    psFree(cell->concepts);
     98    psFree(cell->analysis);
     99    psFree(cell->config);
     100    psFree(cell->hdu);
    105101}
    106102
    107103static void chipFree(pmChip* chip)
    108104{
    109     if (chip != NULL) {
    110         psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent);
    111         if (chip->parent) {
    112             psArray *chips = chip->parent->chips;
    113             for (int i = 0; i < chips->n; i++) {
    114                 if (chips->data[i] == chip) {
    115                     //                    pmChip *tmpChip = chips->data[i];
    116                     chips->data[i] = NULL;
    117                     #if PARENT_LINKS
    118 
    119                     psFree(tmpChip);
    120                     #endif
    121 
    122                     break;
    123                 }
     105    psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent);
     106    if (chip->parent) {
     107        psArray *chips = chip->parent->chips;
     108        for (int i = 0; i < chips->n; i++) {
     109            if (chips->data[i] == chip) {
     110                //                    pmChip *tmpChip = chips->data[i];
     111                chips->data[i] = NULL;
     112                #if PARENT_LINKS
     113
     114                psFree(tmpChip);
     115                #endif
     116
     117                break;
    124118            }
    125119        }
    126         psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip);
    127 
    128         pmChipFreeCells(chip);
    129         psFree(chip->cells);
    130         #if PARENT_LINKS
    131 
    132         psFree(chip->parent);
    133         #endif
    134 
    135         #if 0
    136 
    137         psFree(chip->toFPA);
    138         psFree(chip->fromFPA);
    139         #endif
    140 
    141         psFree(chip->concepts);
    142         psFree(chip->analysis);
    143         psFree(chip->hdu);
    144     }
     120    }
     121    psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip);
     122
     123    pmChipFreeCells(chip);
     124    psFree(chip->cells);
     125    #if PARENT_LINKS
     126
     127    psFree(chip->parent);
     128    #endif
     129
     130    #if 0
     131
     132    psFree(chip->toFPA);
     133    psFree(chip->fromFPA);
     134    #endif
     135
     136    psFree(chip->concepts);
     137    psFree(chip->analysis);
     138    psFree(chip->hdu);
    145139}
    146140
     
    148142static void FPAFree(pmFPA *fpa)
    149143{
    150     if (fpa != NULL) {
    151         psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa);
    152         #if 0
    153 
    154         psFree(fpa->fromTangentPlane);
    155         psFree(fpa->toTangentPlane);
    156         psFree(fpa->projection);
    157         #endif
    158 
    159         psFree(fpa->concepts);
    160         psFree(fpa->analysis);
    161         psFree(fpa->camera);
    162         //
    163         // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)
    164         // in order to avoid memory reference counter problems.
    165         //
    166         psArray *chips = fpa->chips;
    167         for (psS32 i = 0 ; i < chips->n ; i++) {
    168             pmChip *tmpChip = chips->data[i];
    169             if (! tmpChip) {
    170                 continue;
    171             }
    172             chips->data[i] = NULL;
    173             tmpChip->parent = NULL;
    174             if (PS_FREE_HIERARCHY == 1) {
    175                 psFree(tmpChip);
    176             }
    177         }
    178         psFree(fpa->chips);
    179         psFree(fpa->hdu);
    180     }
     144    psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa);
     145    #if 0
     146
     147    psFree(fpa->fromTangentPlane);
     148    psFree(fpa->toTangentPlane);
     149    psFree(fpa->projection);
     150    #endif
     151
     152    psFree(fpa->concepts);
     153    psFree(fpa->analysis);
     154    psFree(fpa->camera);
     155    //
     156    // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)
     157    // in order to avoid memory reference counter problems.
     158    //
     159    psArray *chips = fpa->chips;
     160    for (psS32 i = 0 ; i < chips->n ; i++) {
     161        pmChip *tmpChip = chips->data[i];
     162        if (! tmpChip) {
     163            continue;
     164        }
     165        chips->data[i] = NULL;
     166        tmpChip->parent = NULL;
     167        if (PS_FREE_HIERARCHY == 1) {
     168            psFree(tmpChip);
     169        }
     170    }
     171    psFree(fpa->chips);
     172    psFree(fpa->hdu);
    181173}
    182174
  • branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c

    r6740 r6743  
    373373
    374374                // Put in the extension
    375                 if (chip->hdu) {
    376                     if (chip->hdu != hdu) {
    377                         psLogMsg(__func__, PS_LOG_WARN, "Overwriting HDU in chip %s\n", chipName);
    378                         psFree(chip->hdu);  // Make way!
    379                     }
    380                 } else {
     375                if (chip->hdu && chip->hdu != hdu) {
     376                    psLogMsg(__func__, PS_LOG_WARN, "Overwriting HDU in chip %s\n", chipName);
     377                    psFree(chip->hdu);  // Make way!
     378                    chip->hdu = NULL;
     379                }
     380                if (!chip->hdu) {
    381381                    chip->hdu = psMemIncrRefCounter(hdu);
    382382                }
     
    437437
    438438                // Put in the extension
    439                 if (cell->hdu) {
    440                     if (cell->hdu != hdu) {
    441                         psLogMsg(__func__, PS_LOG_WARN, "Overwriting HDU in chip %s, cell %s\n", chipName,
    442                                  cellName);
    443                         psFree(cell->hdu);
    444                     }
    445                 } else {
     439                if (cell->hdu && cell->hdu != hdu) {
     440                    psLogMsg(__func__, PS_LOG_WARN, "Overwriting HDU in chip %s, cell %s\n", chipName,
     441                             cellName);
     442                    psFree(cell->hdu);
     443                    cell->hdu = NULL;
     444                }
     445                if (! cell->hdu) {
    446446                    cell->hdu = psMemIncrRefCounter(hdu);
    447447                }
  • branches/rel10_ifa/psModules/src/astrom/pmFPACopy.c

    r6734 r6743  
    307307    // Get the size of the HDU, either from existing trimsec and biassec, or generate these and try again
    308308    int xSize = 0, ySize = 0;           // Size of HDU
    309     #if 1
    310 
    311309    if (!sizeHDU(&xSize, &ySize, targetCells) && !(generateTrimBias(targetCells, sourceCells) &&
    312310            sizeHDU(&xSize, &ySize, targetCells))) {
     
    314312        return false;
    315313    }
    316     #else
    317     if (!sizeHDU(&xSize, &ySize, targetCells)) {
    318         if (generateTrimBias(targetCells, sourceCells)) {
    319             if (!sizeHDU(&xSize, &ySize, targetCells)) {
    320                 psError(PS_ERR_IO, true, "Unable to determine size of HDU!\n");
    321                 return false;
    322             }
    323         } else {
    324             psError(PS_ERR_IO, true, "Unable to determine size of HDU!\n");
    325             return false;
    326         }
    327     }
    328     #endif
     314    psFree(targetCells);
     315    psFree(sourceCells);
    329316
    330317    hdu->images = psArrayAlloc(numReadouts);
     
    509496        } else {
    510497            copyPixels(hdu->images->data[i], sourceImage, *trimsec, xFlip, yFlip);
    511             targetReadout->image = psMemIncrRefCounter(psImageSubset(hdu->images->data[i], *trimsec));
     498            targetReadout->image = psImageSubset(hdu->images->data[i], *trimsec);
    512499        }
    513500
     
    532519            } else {
    533520                copyPixels(hdu->images->data[i], bias, *biassec, xFlip, yFlip);
    534                 psImage *newBias = psMemIncrRefCounter(psImageSubset(hdu->images->data[i], *biassec));
     521                psImage *newBias = psImageSubset(hdu->images->data[i], *biassec);
    535522                psListAdd(targetReadout->bias, PS_LIST_TAIL, newBias);
    536523                psFree(newBias);        // Drop reference
    537524            }
    538525        }
     526        psFree(targetReadout);          // Drop reference
    539527        psFree(biassecsIter);
    540528        psFree(biasIter);
     
    551539        }
    552540    }
     541    psFree(conceptsIter);
    553542
    554543    // Need to update CELL.X0 and CELL.Y0 if we flipped
Note: See TracChangeset for help on using the changeset viewer.