Changeset 3407 for trunk/psLib/src/astronomy/psMetadata.c
- Timestamp:
- Mar 11, 2005, 10:38:56 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astronomy/psMetadata.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astronomy/psMetadata.c
r3381 r3407 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.5 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-03- 07 20:58:50$14 * @version $Revision: 1.55 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-03-11 20:38:56 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 /* FUNCTION IMPLEMENTATION - LOCAL */ 68 68 /*****************************************************************************/ 69 70 static psMetadataItem* makeMetaMulti(psHash* table, const char* key, psMetadataItem* existing) 71 { 72 73 if (existing != NULL && existing->type == PS_META_MULTI) { 74 return existing; 75 } 76 77 // move any existing entry into a psList 78 psList* newList = psListAlloc(existing); 79 80 psMetadataItem* item = psMetadataItemAlloc(key, 81 PS_META_MULTI, 82 "", 83 newList); 84 85 if (existing != NULL) { 86 psHashRemove(table,key); // take out the old entry 87 } 88 89 psHashAdd(table, key, item); // put in the new entry 90 91 // free local references of newly allocated items. 92 psFree(newList); 93 psFree(item); 94 95 return item; 96 } 69 97 70 98 static void metadataItemFree(psMetadataItem* metadataItem) … … 253 281 existingEntry = (psMetadataItem*)psHashLookup(mdTable, key); 254 282 255 // how the item is added to the hash depends on flags & prior existence 256 if(existingEntry != NULL) { 257 if ((flags & PS_META_DUPLICATE_OK) != 0) { 283 if (metadataItem->type == PS_META_MULTI) { 284 // the incoming entry is PS_META_MULTI 285 286 // force the hash entry to be PS_META_MULTI 287 existingEntry = makeMetaMulti(mdTable,key,existingEntry); 288 289 // add all the items in the incoming entry to metadata 290 psList* list = metadataItem->data.list; 291 if (list != NULL) { 292 psListIterator* iter = psListIteratorAlloc(list,PS_LIST_HEAD,true); 293 psMetadataItem* listItem; 294 while ((listItem=(psMetadataItem*)psListGetAndIncrement(iter)) != NULL) { 295 psMetadataAddItem(md,listItem,location,flags); 296 } 297 psFree(iter); 298 } 299 300 return true; // all done. 301 } 302 303 // how the item is added to the hash depends on prior existence, flags, etc. 304 if(existingEntry != NULL) { // prior existence 305 if (existingEntry->type == PS_META_MULTI || (flags & PS_META_DUPLICATE_OK) != 0) { 258 306 // duplicate entries allowed - add another entry. 259 if (existingEntry->type != PS_META_MULTI) { 260 // first duplicate, transfer the hash's old entry into a 261 // list of entries with the type PS_META_MULTI. 262 263 // add entry to a list and dereference the local pointer 264 psList* newList = psListAlloc(existingEntry); 265 266 existingEntry = psMetadataItemAlloc(key, 267 PS_META_MULTI, 268 "", 269 newList); 270 psHashRemove(mdTable,key); // take out the old entry 271 psHashAdd(mdTable, key, existingEntry); // put in the new entry 272 273 // free local references of newly allocated items. 274 psFree(newList); 275 psFree(existingEntry); 276 277 } 307 308 // make sure the existing entry is PS_META_MULTI 309 existingEntry = makeMetaMulti(mdTable,key,existingEntry); 278 310 279 311 // add to the hash's list of duplicate entries … … 282 314 return false; 283 315 } 284 // (added to list below)285 286 316 } else if ((flags & PS_META_REPLACE) != 0) { 287 317 // replace entry instead of creating a duplicate entry. 288 318 289 319 // remove the existing entry from metadata 290 psListRemoveData(mdList, existingEntry); 291 psHashRemove(mdTable, key); 320 psMetadataRemove(md,0,key); 292 321 293 322 // treat as if new (added to list below) … … 423 452 // multiple entries with same key, remove just the specified one 424 453 psListRemoveData(tableItem->data.list, entry); 425 if (psListGet(tableItem->data.list,PS_LIST_HEAD) == NULL) {426 // list is empty, so let's clear the whole entry now.427 if (!psHashRemove(mdTable, key)) {428 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, key);429 return false;430 }431 }432 454 } else { 433 455 if (!psHashRemove(mdTable, key)) {
Note:
See TracChangeset
for help on using the changeset viewer.
