Changeset 10503 for trunk/psModules/src/config/pmConfigRecipes.c
- Timestamp:
- Dec 6, 2006, 10:47:26 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigRecipes.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigRecipes.c
r10482 r10503 27 27 // if the recipe is already defined in config->arguments, supplement 28 28 // 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 { 31 35 options = psMetadataAlloc (); 32 36 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); 33 46 } 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; 47 52 } 48 53 … … 163 168 164 169 // 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); 169 178 } 170 179 … … 373 382 374 383 // 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 } 377 390 current = psMetadataCopy (current, recipe); 378 391 psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, … … 402 415 403 416 // search for linkName in config->recipes 404 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, symbolRef); // The source405 if (recipe ) {417 psMetadataItem *recipeItem = psMetadataLookup(config->recipes, symbolRef); 418 if (recipeItem) { 406 419 // if this named recipe exists, supplement it 420 assert(recipeItem->type == PS_DATA_METADATA); 421 psMetadata *recipe = recipeItem->data.V; 407 422 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 410 431 current = psMetadataCopy(current, recipe); 411 432 psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE, … … 418 439 psMetadata *current = psMetadataLookupMetadata(NULL, config->recipes, symbolName); // The source 419 440 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; 423 445 psTrace("psModules.config", 3, "Supplementing %s from %s metadata within %s.\n", 424 446 symbolName, symbolRef, symbolRef); … … 457 479 psMetadataItem *item = NULL; // MD item containing the filename, from recipe iteration 458 480 while ((item = psMetadataGetAndIncrement(recipesIter))) { 459 psMetadata *recipe = NULL;460 psMetadata *current = NULL;461 462 481 // type mismatch is a serious error 463 482 if (item->type != PS_DATA_METADATA) { … … 465 484 } 466 485 // increment the ref counter to protect the data 467 recipe = psMemIncrRefCounter (item->data.V);486 psMetadata *recipe = psMemIncrRefCounter (item->data.V); 468 487 469 488 // 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 } 471 495 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); 473 498 psFree(recipe); // Drop reference 474 499 psFree(current); // Drop reference
Note:
See TracChangeset
for help on using the changeset viewer.
