Changeset 10470
- Timestamp:
- Dec 4, 2006, 6:08:20 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigRecipes.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigRecipes.c
r10436 r10470 286 286 } 287 287 288 psMetadata *recipe = NULL; 289 psMetadata *current = NULL; 290 291 # if (0) 292 293 psString comment = NULL; 288 #if (0) 289 psString comment = NULL; 294 290 psStringAppend(&comment, "Recipe added at %s from %s", sourceName, (char*)fileItem->data.V); 295 291 psTrace ("psModules.pmConfig", 3, comment); 296 292 psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE, comment, sourceType); 297 293 psFree(comment); 298 # endif294 #endif 299 295 300 296 // Read the recipe file. 297 psMetadata *recipe = NULL; 301 298 if (!pmConfigFileRead(&recipe, fileItem->data.V, "recipe")) { 302 299 psError(PS_ERR_IO, false, "Failed to read recipe"); … … 307 304 308 305 // if this named recipe exists, supplement it 309 current = psMemIncrRefCounter (psMetadataLookupMetadata (NULL, config->recipes, fileItem->name)); 306 psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes, 307 fileItem->name)); 310 308 current = psMetadataCopy (current, recipe); 311 psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, current);312 309 psFree(recipe); // Drop reference 310 psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE, 311 fileItem->comment, current); 313 312 psFree(current); // Drop reference 314 313 } … … 340 339 psMetadataItem *item = NULL; // MD item containing the filename, from recipe iteration 341 340 while ((item = psMetadataGetAndIncrement(recipesIter))) { 342 psMetadata *recipe = NULL;343 psMetadata *current = NULL;344 345 341 // type mismatch is a serious error 346 342 if (item->type != PS_DATA_METADATA) { … … 348 344 } 349 345 // increment the ref counter to protect the data 350 recipe = psMemIncrRefCounter (item->data.V); 346 347 psMetadata *recipe = item->data.V; // Recipe of interest 351 348 352 349 // if this named recipe exists, supplement it 353 current = psMemIncrRefCounter (psMetadataLookupMetadata (NULL, config->recipes, item->name)); 350 psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes, 351 item->name)); 354 352 current = psMetadataCopy (current, recipe); 355 psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, "added from command-line recipe", current);356 psFree(recipe); // Drop reference353 psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, 354 "added from command-line recipe", current); 357 355 psFree(current); // Drop reference 358 356 } … … 375 373 while ((item = psMetadataGetAndIncrement(recipesIter))) { 376 374 assert(item->type == PS_DATA_STRING); // It should be this type: we put it in ourselves 377 const char *symbolRef = psStringCopy (item->data.V); // The name of the symbolic reference 378 const char *symbolName = psStringCopy (item->name); 379 380 psMetadata *current = NULL; 381 psMetadata *recipe = NULL; 375 const char *symbolRef = item->data.V; // The name of the symbolic reference 376 const char *symbolName = item->name; 382 377 383 378 // search for linkName in config->recipes 384 recipe = psMetadataLookupMetadata(NULL, config->recipes, symbolRef); // The source379 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, symbolRef); // The source 385 380 if (recipe) { 386 381 // if this named recipe exists, supplement it 387 current = psMemIncrRefCounter (psMetadataLookupMetadata (NULL, config->recipes, symbolName)); 388 current = psMetadataCopy (current, recipe); 389 psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE, symbolRef, current); 382 psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes, 383 symbolName)); 384 current = psMetadataCopy(current, recipe); 385 psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE, 386 symbolRef, current); 390 387 psFree(current); // Drop reference 391 psFree (symbolName);392 psFree (symbolRef);393 388 continue; 394 389 } 395 390 396 391 // search for linkName in config->recipes:NAME 397 current = psMetadataLookupMetadata(NULL, config->recipes, symbolName); // The source392 psMetadata *current = psMetadataLookupMetadata(NULL, config->recipes, symbolName); // The source 398 393 if (current) { 399 394 recipe = psMetadataLookupMetadata(NULL, current, symbolRef); // The source 400 395 if (recipe) { 401 396 // supplement the existing recipe 402 current = psMetadataCopy (current, recipe); 403 psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE, symbolRef, current); 397 psMetadataCopy (current, recipe); 398 psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE, 399 symbolRef, current); 404 400 continue; 405 401 } 406 psFree(recipe); // Drop reference 407 psFree(current); // Drop reference 408 psFree (symbolName); 409 psFree (symbolRef); 410 } 411 psFree (symbolName); 412 psFree (symbolRef); 402 } 413 403 // symbol is not found: ERROR 414 404 }
Note:
See TracChangeset
for help on using the changeset viewer.
