Changeset 2694
- Timestamp:
- Dec 10, 2004, 11:43:16 AM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
psLib.kdevelop.pcs (modified) ( previous)
-
psLib.kdevses (modified) (1 diff)
-
src/collections/psList.c (modified) (11 diffs)
-
src/types/psList.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevses
r2681 r2694 2 2 <!DOCTYPE KDevPrjSession> 3 3 <KDevPrjSession> 4 <DocsAndViews NumberOfDocuments=" 6" >5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/ src/Makefile" >6 <View0 line=" 225" Type="Source" />4 <DocsAndViews NumberOfDocuments="2" > 5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/test/astronomy/tst_psMetadataIO.c" > 6 <View0 line="49" Type="Source" /> 7 7 </Doc0> 8 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/ src/fileUtils/psFits.c" >9 <View0 line=" 585" Type="Source" />8 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/test/astronomy/tst_psMetadata_01.c" > 9 <View0 line="76" Type="Source" /> 10 10 </Doc1> 11 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFits.h" >12 <View0 line="144" Type="Source" />13 </Doc2>14 <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFileUtilsErrors.dat" >15 <View0 line="35" Type="Source" />16 </Doc3>17 <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psList.h" >18 <View0 line="166" Type="Source" />19 </Doc4>20 <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psList.c" >21 <View0 line="46" Type="Source" />22 </Doc5>23 11 </DocsAndViews> 24 12 <pluginList> -
trunk/psLib/src/collections/psList.c
r2681 r2694 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12-10 02:50:14$8 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-10 21:43:16 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 74 74 static psBool listIteratorRemove(psListIterator* iterator) 75 75 { 76 if (iterator == NULL ) {76 if (iterator == NULL || iterator->cursor == NULL) { 77 77 return false; 78 78 } … … 102 102 if (iter->cursor == elem) { 103 103 iter->cursor = NULL; 104 } else if (iter->index > index ) {104 } else if (iter->index > index && iter->index > 0) { 105 105 iter->index--; 106 106 } … … 183 183 psList* list = iterator->list; 184 184 185 if (location >= list->size) {185 if (location >= (int)list->size) { 186 186 psLogMsg(__func__, PS_LOG_WARN, 187 187 "Specified index, %d, is beyond the end of the psList, which " … … 283 283 284 284 psListElem* cursor = iterator->cursor; 285 286 if (cursor == NULL) { 285 psList* list = iterator->list; 286 287 if (cursor == NULL && list->head != NULL) { 287 288 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 288 289 PS_ERRORTEXT_psList_ITERATOR_INVALID); … … 290 291 } 291 292 292 psList* list = iterator->list;293 293 psListElem* elem = psAlloc(sizeof(psListElem)); 294 294 … … 297 297 298 298 // set the new list element's attributes 299 elem->prev = cursor; 300 elem->next = cursor->next; 301 elem->data = data; 302 303 cursor->next = elem; 299 if (cursor == NULL) { // must be an empty list 300 elem->prev = NULL; 301 elem->next = NULL; 302 list->head = elem; 303 list->tail = elem; 304 } else { 305 elem->prev = cursor; 306 elem->next = cursor->next; 307 cursor->next = elem; 308 if (elem->next == NULL) { 309 list->tail = elem; 310 } 311 } 312 313 elem->data = psMemIncrRefCounter(data); 314 304 315 list->size++; 305 316 … … 338 349 339 350 psListElem* cursor = iterator->cursor; 340 341 if (cursor == NULL) { 351 psList* list = iterator->list; 352 353 if (cursor == NULL && list->head != NULL) { 342 354 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 343 355 PS_ERRORTEXT_psList_ITERATOR_INVALID); … … 345 357 } 346 358 347 psList* list = iterator->list;348 359 psListElem* elem = psAlloc(sizeof(psListElem)); 349 360 … … 352 363 353 364 // set the new list element's attributes 354 elem->prev = cursor->prev; 355 elem->next = cursor; 356 elem->data = data; 357 358 cursor->prev = elem; 365 if (cursor == NULL) { // empty list. 366 elem->prev = NULL; 367 elem->next = NULL; 368 list->head = elem; 369 list->tail = elem; 370 } else { 371 elem->prev = cursor->prev; 372 elem->next = cursor; 373 cursor->prev = elem; 374 if (elem->prev == NULL) { 375 list->head = elem; 376 } 377 } 378 379 elem->data = psMemIncrRefCounter(data); 380 359 381 list->size++; 360 382 … … 435 457 psPtr psListGet(psList* list, psS32 location) 436 458 { 459 if (list == NULL) { 460 psError(PS_ERR_BAD_PARAMETER_NULL, true, 461 PS_ERRORTEXT_psList_LIST_NULL); 462 return false; 463 } 464 437 465 psListIterator* iterator = list->iterators->data[0]; 438 466 -
trunk/psLib/src/types/psList.c
r2681 r2694 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12-10 02:50:14$8 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-10 21:43:16 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 74 74 static psBool listIteratorRemove(psListIterator* iterator) 75 75 { 76 if (iterator == NULL ) {76 if (iterator == NULL || iterator->cursor == NULL) { 77 77 return false; 78 78 } … … 102 102 if (iter->cursor == elem) { 103 103 iter->cursor = NULL; 104 } else if (iter->index > index ) {104 } else if (iter->index > index && iter->index > 0) { 105 105 iter->index--; 106 106 } … … 183 183 psList* list = iterator->list; 184 184 185 if (location >= list->size) {185 if (location >= (int)list->size) { 186 186 psLogMsg(__func__, PS_LOG_WARN, 187 187 "Specified index, %d, is beyond the end of the psList, which " … … 283 283 284 284 psListElem* cursor = iterator->cursor; 285 286 if (cursor == NULL) { 285 psList* list = iterator->list; 286 287 if (cursor == NULL && list->head != NULL) { 287 288 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 288 289 PS_ERRORTEXT_psList_ITERATOR_INVALID); … … 290 291 } 291 292 292 psList* list = iterator->list;293 293 psListElem* elem = psAlloc(sizeof(psListElem)); 294 294 … … 297 297 298 298 // set the new list element's attributes 299 elem->prev = cursor; 300 elem->next = cursor->next; 301 elem->data = data; 302 303 cursor->next = elem; 299 if (cursor == NULL) { // must be an empty list 300 elem->prev = NULL; 301 elem->next = NULL; 302 list->head = elem; 303 list->tail = elem; 304 } else { 305 elem->prev = cursor; 306 elem->next = cursor->next; 307 cursor->next = elem; 308 if (elem->next == NULL) { 309 list->tail = elem; 310 } 311 } 312 313 elem->data = psMemIncrRefCounter(data); 314 304 315 list->size++; 305 316 … … 338 349 339 350 psListElem* cursor = iterator->cursor; 340 341 if (cursor == NULL) { 351 psList* list = iterator->list; 352 353 if (cursor == NULL && list->head != NULL) { 342 354 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 343 355 PS_ERRORTEXT_psList_ITERATOR_INVALID); … … 345 357 } 346 358 347 psList* list = iterator->list;348 359 psListElem* elem = psAlloc(sizeof(psListElem)); 349 360 … … 352 363 353 364 // set the new list element's attributes 354 elem->prev = cursor->prev; 355 elem->next = cursor; 356 elem->data = data; 357 358 cursor->prev = elem; 365 if (cursor == NULL) { // empty list. 366 elem->prev = NULL; 367 elem->next = NULL; 368 list->head = elem; 369 list->tail = elem; 370 } else { 371 elem->prev = cursor->prev; 372 elem->next = cursor; 373 cursor->prev = elem; 374 if (elem->prev == NULL) { 375 list->head = elem; 376 } 377 } 378 379 elem->data = psMemIncrRefCounter(data); 380 359 381 list->size++; 360 382 … … 435 457 psPtr psListGet(psList* list, psS32 location) 436 458 { 459 if (list == NULL) { 460 psError(PS_ERR_BAD_PARAMETER_NULL, true, 461 PS_ERRORTEXT_psList_LIST_NULL); 462 return false; 463 } 464 437 465 psListIterator* iterator = list->iterators->data[0]; 438 466
Note:
See TracChangeset
for help on using the changeset viewer.
