IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17988 for trunk/psModules


Ignore:
Timestamp:
Jun 8, 2008, 2:35:06 PM (18 years ago)
Author:
eugene
Message:

free various leaks on error condtions; add return camera and name for pmConfigCameraFormatFromHeader defined FPAs may have a different metaCamera from the camera defined in config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r17911 r17988  
    429429    psMetadata *phu = NULL;
    430430    psMetadata *format = NULL;
     431    psMetadata *camera = NULL;
     432    psString formatName = NULL;
    431433
    432434    // use success to identify valid exit conditions (as opposed to 'argument not supplied')
     
    471473    psFitsClose(fits);
    472474
    473     // determine the current format from the header
    474     // determine camera if not specified already
    475     format = pmConfigCameraFormatFromHeader(config, phu, true);
     475    // Determine the current format from the header; Determine camera if not specified already.
     476    // the returned pointers 'camera' and 'formatName' are allocated here
     477    format = pmConfigCameraFormatFromHeader(&camera, &formatName, config, phu, true);
    476478    if (!format) {
    477479        psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName);
    478480        psFree(phu);
    479         psFree (realName);
     481        psFree(camera);
     482        psFree(formatName);
     483        psFree(realName);
    480484        return NULL;
    481485    }
    482486
    483487    // build the template fpa, set up the basic view
    484     fpa = pmFPAConstruct(config->camera, config->cameraName);
     488    // XXX do we want this to be the baseCamera name or the metaCamera name?
     489    fpa = pmFPAConstruct(camera, config->cameraName);
    485490    if (!fpa) {
    486491        psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName);
    487         psFree (realName);
     492        psFree(phu);
     493        psFree(camera);
     494        psFree(formatName);
     495        psFree(realName);
     496        psFree(format);
    488497        return NULL;
    489498    }
    490499    psFree (realName);
     500    psFree (camera);
    491501
    492502    // load the given filerule (from config->camera) and bind it to the fpa
     
    496506        psError(PS_ERR_IO, false, "file %s not defined\n", filename);
    497507        psFree(phu);
     508        psFree(formatName);
     509        psFree(format);
    498510        psFree(fpa);
    499         psFree(format);
    500         return NULL;
    501     }
    502     psFree (format);
    503     file->format = psMemIncrRefCounter(format);
    504     file->formatName = psStringCopy(config->formatName);
     511        return NULL;
     512    }
     513    file->format = format;
     514    file->formatName = formatName;
    505515
    506516    // adjust the rules to identify these files in the file->names data
    507     psFree (file->filerule);
    508517    file->filerule = psStringCopy("@FILES");
    509518    file->filesrc = psStringCopy("{CHIP.NAME}.{CELL.NAME}");
     
    514523        psFree(phu);
    515524        psFree(fpa);
    516         psFree(format);
    517525        return NULL;
    518526    }
     
    527535            if (!realName) {
    528536                psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]);
     537                psFree(phu);
     538                psFree(fpa);
    529539                return NULL;
    530540            }
     
    534544                psError(PS_ERR_IO, false, "Failed to open file %s\n", realName);
    535545                psFree(realName);
     546                psFree(phu);
     547                psFree(fpa);
    536548                return NULL;
    537549            }
     
    541553                psFree(realName);
    542554                psFitsClose(fits);
     555                psFree(phu);
     556                psFree(fpa);
    543557                return NULL;
    544558            }
     
    548562                psFree(realName);
    549563                psFitsClose(fits);
     564                psFree(phu);
     565                psFree(fpa);
    550566                return NULL;
    551567            }
     
    554570                psFree(realName);
    555571                psFitsClose(fits);
     572                psFree(phu);
     573                psFree(fpa);
    556574                return NULL;
    557575            }
     
    566584            psFree(phu);
    567585            psFree(fpa);
    568             psFree(format);
    569586            return NULL;
    570587        }
     
    670687
    671688        if (!format) {
    672             format = pmConfigCameraFormatFromHeader(config, phu, true);
     689            format = pmConfigCameraFormatFromHeader(NULL, NULL, config, phu, true);
    673690            if (!format) {
    674691                psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName);
     
    716733        psFree(phu);
    717734    }
    718     psFree(file->format);
    719735    file->format = format;
    720736    file->formatName = psStringCopy(config->formatName);
     
    775791    // on first call to this function, config->camera is not set.
    776792    // later calls will give an error if the cameras do not match
    777     format = pmConfigCameraFormatFromHeader (config, phu, true);
     793    psMetadata *camera = NULL;
     794    psString formatName = NULL;
     795    format = pmConfigCameraFormatFromHeader (&camera, &formatName, config, phu, true);
    778796    if (!format) {
    779797        psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", (char *)infiles->data[0]);
    780798        psFree(phu);
     799        psFree(camera);
     800        psFree(formatName);
    781801        return NULL;
    782802    }
    783803
    784804    // build the template fpa, set up the basic view
    785     fpa = pmFPAConstruct(config->camera, config->cameraName);
     805    fpa = pmFPAConstruct (camera, config->cameraName);
    786806    if (!fpa) {
    787807        psError(PS_ERR_IO, false, "Failed to construct FPA from %s", (char *)infiles->data[0]);
    788808        psFree(phu);
     809        psFree(camera);
     810        psFree(formatName);
    789811        psFree(format);
    790812        return NULL;
    791813    }
     814    psFree(camera);
    792815
    793816    // load the given filerule (from config->camera) and bind it to the fpa
     
    802825        return NULL;
    803826    }
    804     psFree (file->format);
    805827    file->format = format;
    806     file->formatName = psStringCopy(config->formatName);
     828    file->formatName = formatName;
    807829
    808830    // adjust the rules to identify these files in the file->names data
    809     psFree (file->filerule);
    810     psFree (file->filesrc);
    811831    file->filerule = psStringCopy ("@FILES");
    812832    file->filesrc = psStringCopy ("{CHIP.NAME}.{CELL.NAME}");
     
    817837        psFree(phu);
    818838        psFree(fpa);
    819         psFree(format);
    820839        return NULL;
    821840    }
     
    827846        psFree(phu);
    828847        psFree(fpa);
    829         psFree(format);
    830848        return NULL;
    831849    }
     
    841859    psFree(view);
    842860    psFree(name);
    843     psFree(format);
    844861
    845862    if (success) {
Note: See TracChangeset for help on using the changeset viewer.