IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 29, 2004, 1:19:11 PM (22 years ago)
Author:
desonia
Message:

added psListSort function and fixed psListRemove to match the new SDRS (i,e.,
the function now returns a bool instead of a void*).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psList.c

    r1111 r1127  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-28 20:36:37 $
     8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-29 23:19:11 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    176176 * Remove an element from a list
    177177 */
    178 void *psListRemove(psList *list, void *data,  int which)
     178bool psListRemove(psList *list, void *data,  int which)
    179179{
    180180    psListElem *elem = NULL;  // element to remove
     
    183183    if (list == NULL) {
    184184        psError(__func__,"list parameter found to be NULL in %s",__func__);
    185         return NULL;
     185        return false;
    186186    }
    187187
     
    204204        if (which == PS_LIST_UNKNOWN) {
    205205            psError(__func__, "Failed to find item in given psList.");
    206             return NULL;
     206            return false;
    207207        }
    208208    }
     
    215215    if (elem == NULL) {
    216216        psError(__func__, "Couldn't position to given index (%d) to remove element from list.",which);
    217         return NULL;
     217        return false;
    218218    }
    219219
     
    245245    ;
    246246
    247     /*
    248      * OK, delete list element and return the data
    249      */
    250     data = elem->data;
     247    // OK, delete list element and its data
     248    psFree(elem->data);
    251249    psFree(elem);
    252     return data;
     250
     251    return true;
    253252}
    254253
     
    460459
    461460
    462 psList* psListSort(psList* list, psCompareFcn compare)
     461psList* psListSort(psList* list, psComparePtrFcn compare)
    463462{
    464463    psVector* vector;
     
    476475    // convert back to linked list
    477476    list = psVectorToList(vector);
     477    psFree(vector);
    478478
    479479    return list;
Note: See TracChangeset for help on using the changeset viewer.