IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 14, 2005, 9:21:41 AM (21 years ago)
Author:
gusciora
Message:

I think I fixed a problem with memory reference counters in the psFree-ing
of pmFPA, Chip, Cell, Readout.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/tst_pmAstrometry.c

    r5028 r5052  
    55 *  @author George Gusciora, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-09-13 20:54:04 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-09-14 19:21:41 $
    99 *
    1010 *  XXX: The meory dereferencing is not quite right with these functions.
     
    110110{
    111111    // XXX: Do something more with these arguments.
    112     /*
    113         const psMetadata *camera = psMetadataAlloc();
    114         psDB *db = NULL;
    115         pmFPA* fpa = pmFPAAlloc(camera, db);
    116         if (fpa == NULL) {
    117             psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
    118             return 1;
    119         }
    120     */
    121     pmFPA* fpa = NULL;
     112    const psMetadata *camera = psMetadataAlloc();
     113    psDB *db = NULL;
     114    pmFPA* fpa = pmFPAAlloc(camera, db);
     115    if (fpa == NULL) {
     116        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
     117        return 1;
     118    }
     119
    122120    pmChip *chip = pmChipAlloc(fpa);
    123121    if (chip == NULL) {
     
    186184    }
    187185
    188     //    psFree(camera);
     186    psFree(fpa);
    189187    psFree(chip);
    190     psFree(fpa);
     188    psFree(camera);
    191189
    192190    return 0;
    193191}
    194192
    195 
    196193static psS32 testCellAlloc(void)
    197194{
    198195    // XXX: Do something more with these arguments.
    199     /*
    200         const psMetadata *camera = psMetadataAlloc();
    201         psDB *db = NULL;
    202         pmFPA* fpa = pmFPAAlloc(camera, db);
    203         if (fpa == NULL) {
    204             psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.n");
    205             return 1;
    206         }
    207      
    208         pmChip *chip = pmChipAlloc(fpa);
    209         if (chip == NULL) {
    210             psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.n");
    211             return 2;
    212         }
    213     */
    214     pmFPA* fpa = NULL;
    215     pmChip *chip = NULL;
     196    const psMetadata *camera = psMetadataAlloc();
     197    psDB *db = NULL;
     198    pmFPA* fpa = pmFPAAlloc(camera, db);
     199    if (fpa == NULL) {
     200        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.n");
     201        return 1;
     202    }
     203
     204    pmChip *chip = pmChipAlloc(fpa);
     205    if (chip == NULL) {
     206        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.n");
     207        return 2;
     208    }
     209
    216210    pmCell *cell = pmCellAlloc(chip);
    217211    if (cell == NULL) {
     
    288282    psFree(chip);
    289283    psFree(cell);
     284    psFree(camera);
    290285
    291286    return 0;
     
    295290{
    296291    // XXX: Do something more with these arguments.
    297     /*
    298         const psMetadata *camera = psMetadataAlloc();
    299         psDB *db = NULL;
    300         pmFPA* fpa = pmFPAAlloc(camera, db);
    301      
    302         if (fpa == NULL) {
    303             psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.\n");
    304             return 1;
    305         }
    306      
    307         pmChip *chip = pmChipAlloc(fpa);
    308         if (chip == NULL) {
    309             psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.\n");
    310             return 2;
    311         }
    312      
    313         pmCell *cell = pmCellAlloc(chip);
    314         if (cell == NULL) {
    315             psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.\n");
    316             return 3;
    317         }
    318     */
    319 
    320     pmFPA* fpa = NULL;
    321     pmChip *chip = NULL;
    322     pmCell *cell = NULL;
     292    const psMetadata *camera = psMetadataAlloc();
     293    psDB *db = NULL;
     294    pmFPA* fpa = pmFPAAlloc(camera, db);
     295
     296    if (fpa == NULL) {
     297        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.\n");
     298        return 1;
     299    }
     300
     301    pmChip *chip = pmChipAlloc(fpa);
     302    if (chip == NULL) {
     303        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.\n");
     304        return 2;
     305    }
     306
     307    pmCell *cell = pmCellAlloc(chip);
     308    if (cell == NULL) {
     309        psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.\n");
     310        return 3;
     311    }
     312
    323313    pmReadout *readout = pmReadoutAlloc(cell);
    324314    if (readout == NULL) {
     
    376366    psFree(cell);
    377367    psFree(readout);
     368    psFree(camera);
    378369
    379370    return 0;
Note: See TracChangeset for help on using the changeset viewer.