IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10503


Ignore:
Timestamp:
Dec 6, 2006, 10:47:26 AM (19 years ago)
Author:
Paul Price
Message:

Replacing psMetadataLookupMetadata with psMetadataLookup to avoid unnecessary errors.

File:
1 edited

Legend:

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

    r10482 r10503  
    2727    // if the recipe is already defined in config->arguments, supplement
    2828    // save the recipe options onto config->arguments:RECIPES
    29     psMetadata *options = psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS");
    30     if (!options) {
     29    psMetadata *options;
     30    psMetadataItem *optionsItem = psMetadataLookup(config->arguments, "OPTIONS");
     31    if (optionsItem) {
     32        assert(optionsItem->type == PS_DATA_METADATA);
     33        options = psMemIncrRefCounter(optionsItem->data.V);
     34    } else {
    3135        options = psMetadataAlloc ();
    3236        psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "", options);
     37    }
     38
     39    // look for the recipe defined in recipes
     40    psMetadata *recipe;
     41    psMetadataItem *recipeItem = psMetadataLookup(options, recipeName);
     42    psFree(options);                   // Drop reference
     43    if (recipeItem) {
     44        assert(recipeItem->type == PS_DATA_METADATA);
     45        recipe = psMemIncrRefCounter(recipeItem->data.V);
    3346    } else {
    34         psMemIncrRefCounter (options); // so we can free options below if not allocated here
    35     }
    36 
    37     // look for the recipe defined in recipes
    38     psMetadata *recipe = psMetadataLookupMetadata(NULL, options, recipeName);
    39     if (!recipe) {
    40         recipe = psMetadataAlloc ();
    41         psMetadataAddPtr (options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
    42     } else {
    43         psMemIncrRefCounter (recipe); // so we can free options below if not allocated here
    44     }
    45     psFree (options);
    46     return (recipe);
     47        recipe = psMetadataAlloc();
     48        psMetadataAddPtr(options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
     49    }
     50
     51    return recipe;
    4752}
    4853
     
    163168
    164169        // if this recipe is already defined in options, supplement
    165         psMetadata *recipe = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, options, recipeName));
    166         if (!recipe) {
    167             recipe = psMetadataAlloc ();
    168             psMetadataAddPtr (options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
     170        psMetadata *recipe;
     171        psMetadataItem *recipeItem = psMetadataLookup(options, recipeName);
     172        if (recipeItem) {
     173            assert(recipeItem->type == PS_DATA_METADATA);
     174            recipe = psMemIncrRefCounter(recipeItem->data.V);
     175        } else {
     176            recipe = psMetadataAlloc();
     177            psMetadataAddPtr(options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
    169178        }
    170179
     
    373382
    374383        // if this named recipe exists, supplement it
    375         psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes,
    376                               item->name));
     384        psMetadata *current = NULL;
     385        psMetadataItem *currentItem = psMetadataLookup(config->recipes, item->name);
     386        if (currentItem) {
     387            assert(currentItem->type == PS_DATA_METADATA);
     388            current = psMemIncrRefCounter(currentItem->data.V);
     389        }
    377390        current = psMetadataCopy (current, recipe);
    378391        psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
     
    402415
    403416        // search for linkName in config->recipes
    404         psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, symbolRef); // The source
    405         if (recipe) {
     417        psMetadataItem *recipeItem = psMetadataLookup(config->recipes, symbolRef);
     418        if (recipeItem) {
    406419            // if this named recipe exists, supplement it
     420            assert(recipeItem->type == PS_DATA_METADATA);
     421            psMetadata *recipe = recipeItem->data.V;
    407422            psTrace("psModules.config", 3, "Supplementing %s from %s.\n", symbolName, symbolRef);
    408             psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes,
    409                                   symbolName));
     423
     424            psMetadata *current = NULL;
     425            psMetadataItem *currentItem = psMetadataLookup(config->recipes, symbolName);
     426            if (currentItem) {
     427                assert(currentItem->type == PS_DATA_METADATA);
     428                current = psMemIncrRefCounter(currentItem->data.V);
     429            }
     430
    410431            current = psMetadataCopy(current, recipe);
    411432            psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE,
     
    418439        psMetadata *current = psMetadataLookupMetadata(NULL, config->recipes, symbolName); // The source
    419440        if (current) {
    420             recipe = psMetadataLookupMetadata(NULL, current, symbolRef); // The source
    421             if (recipe) {
    422                 // supplement the existing recipe
     441            psMetadataItem *recipeItem = psMetadataLookup(current, symbolRef);
     442            if (recipeItem) {
     443                assert(recipeItem->type == PS_DATA_METADATA);
     444                psMetadata *recipe = recipeItem->data.V;
    423445                psTrace("psModules.config", 3, "Supplementing %s from %s metadata within %s.\n",
    424446                        symbolName, symbolRef, symbolRef);
     
    457479    psMetadataItem *item = NULL;    // MD item containing the filename, from recipe iteration
    458480    while ((item = psMetadataGetAndIncrement(recipesIter))) {
    459         psMetadata *recipe = NULL;
    460         psMetadata *current = NULL;
    461 
    462481        // type mismatch is a serious error
    463482        if (item->type != PS_DATA_METADATA) {
     
    465484        }
    466485        // increment the ref counter to protect the data
    467         recipe = psMemIncrRefCounter (item->data.V);
     486        psMetadata *recipe = psMemIncrRefCounter (item->data.V);
    468487
    469488        // if this named recipe exists, supplement it
    470         current = psMemIncrRefCounter (psMetadataLookupMetadata (NULL, config->recipes, item->name));
     489        psMetadata *current = NULL;
     490        psMetadataItem *currentItem = psMetadataLookup(config->recipes, item->name);
     491        if (currentItem) {
     492            assert(currentItem->type == PS_DATA_METADATA);
     493            current = psMemIncrRefCounter(currentItem->data.V);
     494        }
    471495        current = psMetadataCopy (current, recipe);
    472         psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, "supplement command-line arguments", current);
     496        psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
     497                      "supplement command-line arguments", current);
    473498        psFree(recipe);  // Drop reference
    474499        psFree(current);  // Drop reference
Note: See TracChangeset for help on using the changeset viewer.