Changeset 1073 for trunk/psLib/src/collections
- Timestamp:
- Jun 23, 2004, 1:00:17 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 8 edited
-
psBitSet.c (modified) (5 diffs)
-
psBitSet.h (modified) (2 diffs)
-
psList.c (modified) (7 diffs)
-
psList.h (modified) (2 diffs)
-
psSort.c (modified) (3 diffs)
-
psSort.d (modified) (1 diff)
-
psVector.c (modified) (7 diffs)
-
psVector.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psBitSet.c
r1041 r1073 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06- 15 02:45:43$12 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-23 23:00:15 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 55 55 /* FUNCTION IMPLEMENTATION - LOCAL */ 56 56 /*****************************************************************************/ 57 static void bitSetFree(psBitSet *restrict inBitSet); 58 57 59 58 60 /** Private function to create a mask. … … 88 90 numBytes = ceil(n/8.0); 89 91 newObj = psAlloc(sizeof(psBitSet)); 92 p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree); 90 93 newObj->n = numBytes; 91 94 … … 98 101 } 99 102 100 void psBitSetFree(psBitSet *restrict inBitSet)103 static void bitSetFree(psBitSet *restrict inBitSet) 101 104 { 102 105 if(inBitSet == NULL) { … … 105 108 } 106 109 psFree(inBitSet->bits); 107 psFree(inBitSet);108 110 } 109 111 -
trunk/psLib/src/collections/psBitSet.h
r974 r1073 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-06- 10 01:58:06$14 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-06-23 23:00:15 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 54 54 psBitSet* psBitSetAlloc( 55 55 int n /**< Number of bits in psBitSet array */ 56 );57 58 /** Free a psBitSet59 *60 * Deletes a psBitSet array.61 */62 void psBitSetFree(63 psBitSet *restrict inMask /**< Pointer to psBitSet to be deleted. */64 56 ); 65 57 -
trunk/psLib/src/collections/psList.c
r1024 r1073 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06- 14 19:45:46$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-23 23:00:15 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 29 29 // private functions. 30 psListElem* listGetIterator(psList* list); 31 int listGetIteratorIndex(psList* list); 32 void listSetIterator(psList *list, int where, bool lockList); 30 static psListElem* listGetIterator(psList* list); 31 static int listGetIteratorIndex(psList* list); 32 static void listSetIterator(psList *list, int where, bool lockList); 33 static void listFree(psList *list); 33 34 34 35 … … 36 37 { 37 38 psList *list = psAlloc(sizeof(psList)); 39 p_psMemSetDeallocator(list,(psFreeFcn)listFree); 38 40 39 41 list->size = 0; … … 41 43 list->iter = ITER_INIT_HEAD; 42 44 list->iterIndex = PS_LIST_HEAD; 45 43 46 pthread_mutex_init(&(list->lock),NULL) 44 47 ; … … 51 54 } 52 55 53 void psListFree(psList *list, psFreeFcn elemFree)56 static void listFree(psList *list) 54 57 { 55 58 if (list == NULL) { … … 63 66 psListElem *next = ptr->next; 64 67 65 p _psCustomFree(elemFree, psMemDecrRefCounter(ptr->data));68 psFree(ptr->data); 66 69 psFree(ptr); 67 70 … … 75 78 ; 76 79 77 psFree(list);78 80 } 79 81 -
trunk/psLib/src/collections/psList.h
r1017 r1073 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06- 12 22:15:39$12 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-23 23:00:15 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 73 73 ) 74 74 ; 75 76 #include "psMemory.h"77 /** Destroys a psList linked list object. This also frees the elements of the78 * list using the psFreeFcn given, if any. If no psFreeFcn is specified,79 * the elements are just dereferenced via psMemDecrRefCounter(...).80 *81 */82 void psListFree(83 psList* restrict list, ///< list to destroy84 psFreeFcn elemFree ///< destructor for data on list85 );86 75 87 76 /** Adds an element to a psList at position given. -
trunk/psLib/src/collections/psSort.c
r989 r1073 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-06- 10 23:15:08$16 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-06-23 23:00:15 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 #include "psSort.h" 34 34 #include "psError.h" 35 #include "psMemory.h" 35 36 36 37 /******************************************************************************/ … … 242 243 243 244 // Free temp memory 244 ps VectorFree(tmpVector);245 psFree(tmpVector); 245 246 246 247 return outVector; -
trunk/psLib/src/collections/psSort.d
r986 r1073 1 psSort.o psSort.d : psSort.c psVector.h psType.h psSort.h ../sysUtils/psError.h 1 psSort.o psSort.d : psSort.c psVector.h psType.h psSort.h ../sysUtils/psError.h \ 2 ../sysUtils/psMemory.h -
trunk/psLib/src/collections/psVector.c
r1008 r1073 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-06- 12 01:33:16$10 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-06-23 23:00:15 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 49 49 /* FUNCTION IMPLEMENTATION - LOCAL */ 50 50 /*****************************************************************************/ 51 static void vectorFree(psVector *restrict psVec); 51 52 52 53 /*****************************************************************************/ … … 68 69 // Create vector struct 69 70 psVec = (psVector *)psAlloc(sizeof(psVector)); 71 p_psMemSetDeallocator(psVec,(psFreeFcn)vectorFree); 70 72 71 73 psVec->type.dimen = PS_DIMEN_VECTOR; … … 132 134 if(nalloc < 1) { 133 135 psError(__func__, "Invalid value for nalloc (%d)\n", nalloc); 134 ps VectorFree(in);136 psFree(in); 135 137 return NULL; 136 138 } … … 154 156 } 155 157 156 void psVectorFree(psVector *restrict psVec)158 static void vectorFree(psVector *restrict psVec) 157 159 { 158 160 if (psVec == NULL) { … … 160 162 } 161 163 164 if (psVec->type.type == PS_TYPE_PTR) { 165 for(int i = 0; i < psVec->n; i++) { 166 psFree(psVec->data.PTR[i]); 167 psVec->data.PTR[i] = NULL; 168 } 169 } 170 162 171 psFree(psVec->data.V); 163 psFree(psVec);164 172 } 165 173 166 void psVectorElementFree(psVector *restrict psVec , void (*elemFree)(void *))174 void psVectorElementFree(psVector *restrict psVec) 167 175 { 168 176 … … 176 184 } 177 185 178 for(int i = 0; i < psVec->nalloc; i++) { 179 if(elemFree == NULL) { 180 psMemDecrRefCounter(psVec->data.PTR[i]); 181 } else { 182 elemFree(psMemDecrRefCounter(psVec->data.PTR[i])); 183 } 186 for(int i = 0; i < psVec->n; i++) { 187 psFree(psVec->data.PTR[i]); 184 188 psVec->data.PTR[i] = NULL; 185 189 } -
trunk/psLib/src/collections/psVector.h
r974 r1073 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-06- 10 01:58:06$13 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-06-23 23:00:15 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 100 100 ); 101 101 102 /** Deallocate a vector.103 *104 * Uses psLib memory allocation functions to deallocate a vector collection of data. The vector is deallocated105 * according to the psType type member contained within the vector.106 *107 * @return psVector*: Pointer to psVector.108 *109 */110 void psVectorFree(111 psVector *restrict psVec ///< Vector to free.112 );113 114 115 102 /** Deallocate/Dereference elements of a void pointer vector. 116 103 * … … 122 109 */ 123 110 void psVectorElementFree( 124 psVector *restrict psVec, ///< Void pointer vector to destroy. 125 void (*elemFree)(void *) ///< Optional callback function to remove vector elements. 111 psVector *restrict psVec ///< Void pointer vector to destroy. 126 112 ); 127 113
Note:
See TracChangeset
for help on using the changeset viewer.
