Changeset 1193 for trunk/psLib/src/collections
- Timestamp:
- Jul 7, 2004, 3:05:01 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psList.c
r1127 r1193 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-29 23:19:11$8 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 80 80 } 81 81 82 psList*psListAdd(psList *list, void *data, int where)82 bool psListAdd(psList *list, void *data, int where) 83 83 { 84 84 psListElem* position; … … 87 87 88 88 if (list == NULL) { 89 return NULL;89 return false; 90 90 } 91 91 92 92 if (data == NULL) { 93 return list; 94 } 95 elem = psAlloc(sizeof(psListElem)); 96 97 pthread_mutex_lock(&list->lock) 98 ; 93 return false; 94 } 99 95 100 96 if (where <= PS_LIST_UNKNOWN) { 101 97 /// XXX What is the better way to communicate this failure to the caller? 102 98 psLogMsg(__func__,PS_LOG_WARN, 103 "The given insert location (%i) for psListAdd is invalid. Adding to head instead.",99 "The given insert location (%i) for psListAdd is invalid.", 104 100 where); 105 where = PS_LIST_HEAD; // given I can't tell caller about this, should just add it somewhere??? 106 } 101 return false; 102 } 103 104 elem = psAlloc(sizeof(psListElem)); 105 106 pthread_mutex_lock(&list->lock) 107 ; 107 108 108 109 if (where > 0 && where > list->size) { … … 162 163 ; 163 164 164 return list; 165 } 166 167 /*****************************************************************************/ 168 169 psList *psListAppend(psList *list, void *data) 170 { 171 return psListAdd(list, data, PS_LIST_TAIL); 165 return true; 172 166 } 173 167 … … 452 446 n = arr->n; 453 447 for (int i = 0; i < n; i++) { 454 psListA ppend(list,arr->data.PTR[i]);448 psListAdd(list,arr->data.PTR[i],PS_LIST_TAIL); 455 449 } 456 450 -
trunk/psLib/src/collections/psList.h
r1127 r1193 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-0 6-29 23:19:11$12 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-08 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 81 81 * NULL, the return value will also be NULL. 82 82 */ 83 psList*psListAdd(83 bool psListAdd( 84 84 psList* restrict list, ///< list to add to (if NULL, nothing is done) 85 85 void* data, ///< data item to add. If NULL, list is not modified. 86 86 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 87 );88 89 /** Appends an item to a psList.90 *91 * @return psList* The psList with added data item. If list parameter is92 * NULL, the return value will also be NULL.93 */94 psList* psListAppend(95 psList* restrict list, ///< list to append to (if NULL, nothing is done)96 void *data ///< data item to add. If NULL, list is not modified.97 87 ); 98 88
Note:
See TracChangeset
for help on using the changeset viewer.
