IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13858


Ignore:
Timestamp:
Jun 16, 2007, 3:18:08 PM (19 years ago)
Author:
Paul Price
Message:

Squashing memory leaks involving multiple camera/formats.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r13833 r13858  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-06-14 20:56:57 $
     6 *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-06-17 01:18:08 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    700700                continue;
    701701            }
    702             psMetadata *newRule = psMetadataLookupMetadata(NULL, filerules, new); // New rule (replacement)
    703             if (!newRule) {
     702            psMetadataItem *newItem = psMetadataLookup(filerules, new); // The rule of interest, or a redir.
     703            if (!newItem) {
    704704                psWarning("Can't find file rule %s in camera %s --- ignored.", new, cameraItem->name);
     705                continue;
     706            }
     707            psMetadata *newRule;        // New rule (replacement)
     708            switch (newItem->type) {
     709              case PS_DATA_STRING:
     710                // A redirection
     711                newRule = psMetadataLookupMetadata(NULL, filerules, newItem->data.str);
     712                break;
     713              case PS_DATA_METADATA:
     714                // The rule itself
     715                newRule = newItem->data.md;
     716                break;
     717              default:
     718                psWarning("Unable to find filerule %s of the correct type in camera %s --- ignored.",
     719                          new, cameraItem->name);
    705720                continue;
    706721            }
     
    940955            psMetadata *testCamera = camerasItem->data.md; // Camera to test against what we've got:
    941956            if (formatFromHeader(&format, &name, testCamera, header, camerasItem->name)) {
    942                 config->camera = psMemIncrRefCounter(testCamera);
    943                 config->cameraName = psStringCopy(camerasItem->name);
    944                 config->formatName = name;
    945                 config->format = format;
     957                // Set the defaults, if they are not already set
     958                if (!config->camera && !config->cameraName) {
     959                    config->camera = psMemIncrRefCounter(testCamera);
     960                    config->cameraName = psStringCopy(camerasItem->name);
     961                }
     962                if (!config->format && !config->formatName) {
     963                    config->formatName = name;
     964                    config->format = format;
     965                } else {
     966                    psFree(name);
     967                    psFree(format);
     968                }
    946969            } else {
    947970                psErr *error = psErrorLast();
     
    975998    }
    976999
    977     // Free the format and name just in case they've already been allocated
    978     if (config->format || config->formatName) {
    979         if (config->format != format || strcmp(config->formatName, name) != 0) {
    980             psWarning("Default camera format configuration has changed!\n");
    981         }
    982         psFree(config->format);
    983         psFree(config->formatName);
    984     }
    985     config->formatName = name;
    986     config->format = format;
    987     return psMemIncrRefCounter(format);
     1000    if (!config->format && !config->formatName) {
     1001        config->formatName = name;
     1002        config->format = format;
     1003    } else {
     1004        psFree(name);
     1005    }
     1006    return format;
    9881007}
    9891008
Note: See TracChangeset for help on using the changeset viewer.