Changeset 1073 for trunk/psLib/src
- Timestamp:
- Jun 23, 2004, 1:00:17 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 42 edited
-
collections/psBitSet.c (modified) (5 diffs)
-
collections/psBitSet.h (modified) (2 diffs)
-
collections/psList.c (modified) (7 diffs)
-
collections/psList.h (modified) (2 diffs)
-
collections/psSort.c (modified) (3 diffs)
-
collections/psSort.d (modified) (1 diff)
-
collections/psVector.c (modified) (7 diffs)
-
collections/psVector.h (modified) (3 diffs)
-
dataManip/psFFT.c (modified) (37 diffs)
-
dataManip/psFunctions.c (modified) (18 diffs)
-
dataManip/psFunctions.h (modified) (3 diffs)
-
dataManip/psStats.c (modified) (12 diffs)
-
dataManip/psStats.h (modified) (3 diffs)
-
dataManip/psVectorFFT.c (modified) (37 diffs)
-
fft/psVectorFFT.c (modified) (37 diffs)
-
image/psImage.c (modified) (21 diffs)
-
image/psImage.h (modified) (2 diffs)
-
image/psImageIO.c (modified) (12 diffs)
-
image/psImageIO.d (modified) (1 diff)
-
image/psImageStats.c (modified) (4 diffs)
-
imageops/psImageStats.c (modified) (4 diffs)
-
math/psPolynomial.c (modified) (18 diffs)
-
math/psPolynomial.h (modified) (3 diffs)
-
math/psSpline.c (modified) (18 diffs)
-
math/psSpline.h (modified) (3 diffs)
-
math/psStats.c (modified) (12 diffs)
-
math/psStats.h (modified) (3 diffs)
-
mathtypes/psImage.c (modified) (21 diffs)
-
mathtypes/psImage.h (modified) (2 diffs)
-
mathtypes/psVector.c (modified) (7 diffs)
-
mathtypes/psVector.h (modified) (3 diffs)
-
sys/psMemory.c (modified) (19 diffs)
-
sys/psMemory.h (modified) (6 diffs)
-
sysUtils/psHash.c (modified) (21 diffs)
-
sysUtils/psHash.d (modified) (1 diff)
-
sysUtils/psHash.h (modified) (2 diffs)
-
sysUtils/psMemory.c (modified) (19 diffs)
-
sysUtils/psMemory.h (modified) (6 diffs)
-
types/psBitSet.c (modified) (5 diffs)
-
types/psBitSet.h (modified) (2 diffs)
-
types/psList.c (modified) (7 diffs)
-
types/psList.h (modified) (2 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 -
trunk/psLib/src/dataManip/psFFT.c
r1010 r1073 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-06- 12 02:17:25 $7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-06-23 23:00:15 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 /* got good image data? */ 36 36 if (in==NULL) { 37 ps ImageFree(out);37 psFree(out); 38 38 return NULL; 39 39 } … … 44 44 psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)", 45 45 type); 46 ps ImageFree(out);46 psFree(out); 47 47 return NULL; 48 48 } … … 51 51 psError(__func__,"Input image must be complex image for reverse FFT (type=%d).", 52 52 type); 53 ps ImageFree(out);53 psFree(out); 54 54 return NULL; 55 55 … … 76 76 if (plan == NULL) { 77 77 psError(__func__,"Failed to create FFTW plan."); 78 ps ImageFree(out);78 psFree(out); 79 79 return NULL; 80 80 } … … 98 98 99 99 if (in == NULL) { 100 ps ImageFree(out);100 psFree(out); 101 101 return NULL; 102 102 } … … 143 143 psError(__func__,"Can not extract real component from given image type (%d).", 144 144 type); 145 ps ImageFree(out);145 psFree(out); 146 146 return NULL; 147 147 } … … 158 158 159 159 if (in == NULL) { 160 ps ImageFree(out);160 psFree(out); 161 161 return NULL; 162 162 } … … 205 205 psError(__func__,"Can not extract imaginary component from given image type (%d).", 206 206 type); 207 ps ImageFree(out);207 psFree(out); 208 208 return NULL; 209 209 } … … 220 220 221 221 if (real == NULL || imag == NULL) { 222 ps ImageFree(out);222 psFree(out); 223 223 return NULL; 224 224 } … … 230 230 if (imag->type.type != type) { 231 231 psError(__func__,"The inputs to psImageComplex must be the same type."); 232 ps ImageFree(out);232 psFree(out); 233 233 return NULL; 234 234 } … … 237 237 imag->numRows != numRows) { 238 238 psError(__func__,"The inputs to psImageComplex must be the same dimensions."); 239 ps ImageFree(out);239 psFree(out); 240 240 return NULL; 241 241 } … … 243 243 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 244 244 psError(__func__,"The inputs to psImageComplex can not be complex."); 245 ps ImageFree(out);245 psFree(out); 246 246 return NULL; 247 247 } … … 249 249 if (type != PS_TYPE_F32 && type != PS_TYPE_F64) { 250 250 psError(__func__,"The input type to psImageComplex must be a floating point."); 251 ps ImageFree(out);251 psFree(out); 252 252 return NULL; 253 253 } … … 287 287 psError(__func__,"Can not merge real and imaginary portions for given image type (%d).", 288 288 type); 289 ps ImageFree(out);289 psFree(out); 290 290 return NULL; 291 291 } … … 302 302 303 303 if (in == NULL) { 304 ps ImageFree(out);304 psFree(out); 305 305 return NULL; 306 306 } … … 347 347 psError(__func__,"Can not compute complex conjugate for given image type (%d).", 348 348 type); 349 ps ImageFree(out);349 psFree(out); 350 350 return NULL; 351 351 } … … 362 362 363 363 if (in == NULL) { 364 ps ImageFree(out);364 psFree(out); 365 365 return NULL; 366 366 } … … 374 374 if (! PS_IS_PSELEMTYPE_COMPLEX(type)) { 375 375 psError(__func__,"Power Spectrum for non-complex inputs is not implemented."); 376 ps ImageFree(out);376 psFree(out); 377 377 return NULL; 378 378 } … … 417 417 psError(__func__,"Can not power spectrum for given image type (%d).", 418 418 type); 419 ps ImageFree(out);419 psFree(out); 420 420 return NULL; 421 421 } … … 435 435 /* got good image data? */ 436 436 if (in==NULL) { 437 ps VectorFree(out);437 psFree(out); 438 438 return NULL; 439 439 } … … 444 444 psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)", 445 445 type); 446 ps VectorFree(out);446 psFree(out); 447 447 return NULL; 448 448 } … … 451 451 psError(__func__,"Input image must be complex image for reverse FFT (type=%d).", 452 452 type); 453 ps VectorFree(out);453 psFree(out); 454 454 return NULL; 455 455 … … 491 491 if (plan == NULL) { 492 492 psError(__func__,"Failed to create FFTW plan."); 493 ps VectorFree(out);493 psFree(out); 494 494 return NULL; 495 495 } … … 510 510 511 511 if (in == NULL) { 512 ps VectorFree(out);512 psFree(out); 513 513 return NULL; 514 514 } … … 542 542 psError(__func__,"Can not extract real component from given vector type (%d).", 543 543 type); 544 ps VectorFree(out);544 psFree(out); 545 545 return NULL; 546 546 } … … 556 556 557 557 if (in == NULL) { 558 ps VectorFree(out);558 psFree(out); 559 559 return NULL; 560 560 } … … 588 588 psError(__func__,"Can not extract imaginary component from given vector type (%d).", 589 589 type); 590 ps VectorFree(out);590 psFree(out); 591 591 return NULL; 592 592 } … … 602 602 603 603 if (real == NULL || imag == NULL) { 604 ps VectorFree(out);604 psFree(out); 605 605 return NULL; 606 606 } … … 615 615 if (imag->type.type != type) { 616 616 psError(__func__,"The inputs to psVectorComplex must be the same type."); 617 ps VectorFree(out);617 psFree(out); 618 618 return NULL; 619 619 } … … 621 621 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 622 622 psError(__func__,"The inputs to psVectorComplex can not be complex."); 623 ps VectorFree(out);623 psFree(out); 624 624 return NULL; 625 625 } … … 640 640 psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).", 641 641 type); 642 ps VectorFree(out);642 psFree(out); 643 643 return NULL; 644 644 } … … 654 654 655 655 if (in == NULL) { 656 ps VectorFree(out);656 psFree(out); 657 657 return NULL; 658 658 } … … 687 687 psError(__func__,"Can not compute complex conjugate for given vector type (%d).", 688 688 type); 689 ps VectorFree(out);689 psFree(out); 690 690 return NULL; 691 691 } … … 703 703 704 704 if (in == NULL) { 705 ps VectorFree(out);705 psFree(out); 706 706 return NULL; 707 707 } … … 716 716 if (! PS_IS_PSELEMTYPE_COMPLEX(type)) { 717 717 psError(__func__,"Power Spectrum for non-complex inputs is not implemented."); 718 ps VectorFree(out);718 psFree(out); 719 719 return NULL; 720 720 } … … 747 747 psError(__func__,"Can not power spectrum for given vector type (%d).", 748 748 type); 749 ps VectorFree(out);750 return NULL; 751 } 752 753 return out; 754 755 } 749 psFree(out); 750 return NULL; 751 } 752 753 return out; 754 755 } -
trunk/psLib/src/dataManip/psFunctions.c
r1022 r1073 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-06- 14 19:40:14$9 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-06-23 23:00:15 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 #include <gsl/gsl_rng.h> 35 35 #include <gsl/gsl_randist.h> 36 37 static void polynomial1DFree(psPolynomial1D *myPoly); 38 static void polynomial2DFree(psPolynomial2D *myPoly); 39 static void polynomial3DFree(psPolynomial3D *myPoly); 40 static void polynomial4DFree(psPolynomial4D *myPoly); 41 static void dPolynomial1DFree(psDPolynomial1D *myPoly); 42 static void dPolynomial2DFree(psDPolynomial2D *myPoly); 43 static void dPolynomial3DFree(psDPolynomial3D *myPoly); 44 static void dPolynomial4DFree(psDPolynomial4D *myPoly); 45 36 46 /*****************************************************************************/ 37 47 /* FUNCTION IMPLEMENTATION - PUBLIC */ … … 108 118 109 119 newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D)); 120 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree); 110 121 newPoly->n = n; 111 122 newPoly->coeff = (float *) psAlloc(n * sizeof(float)); … … 128 139 129 140 newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D)); 141 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree); 130 142 newPoly->nX = nX; 131 143 newPoly->nY = nY; … … 158 170 159 171 newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D)); 172 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree); 160 173 newPoly->nX = nX; 161 174 newPoly->nY = nY; … … 197 210 198 211 newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D)); 212 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree); 199 213 newPoly->nW = nW; 200 214 newPoly->nX = nX; … … 235 249 } 236 250 237 void psPolynomial1DFree(psPolynomial1D *myPoly)251 static void polynomial1DFree(psPolynomial1D *myPoly) 238 252 { 239 253 psFree(myPoly->coeff); 240 254 psFree(myPoly->coeffErr); 241 255 psFree(myPoly->mask); 242 psFree(myPoly); 243 } 244 245 void psPolynomial2DFree(psPolynomial2D *myPoly) 256 } 257 258 static void polynomial2DFree(psPolynomial2D *myPoly) 246 259 { 247 260 int x = 0; … … 255 268 psFree(myPoly->coeffErr); 256 269 psFree(myPoly->mask); 257 258 psFree(myPoly); 259 } 260 261 void psPolynomial3DFree(psPolynomial3D *myPoly) 270 } 271 272 static void polynomial3DFree(psPolynomial3D *myPoly) 262 273 { 263 274 int x = 0; … … 278 289 psFree(myPoly->coeffErr); 279 290 psFree(myPoly->mask); 280 psFree(myPoly); 281 } 282 283 void psPolynomial4DFree(psPolynomial4D *myPoly) 291 } 292 293 static void polynomial4DFree(psPolynomial4D *myPoly) 284 294 { 285 295 int w = 0; … … 306 316 psFree(myPoly->coeffErr); 307 317 psFree(myPoly->mask); 308 psFree(myPoly);309 318 } 310 319 … … 434 443 435 444 newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D)); 445 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree); 436 446 newPoly->n = n; 437 447 newPoly->coeff = (double *) psAlloc(n * sizeof(double)); … … 454 464 455 465 newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D)); 466 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree); 456 467 newPoly->nX = nX; 457 468 newPoly->nY = nY; … … 484 495 485 496 newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D)); 497 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree); 486 498 newPoly->nX = nX; 487 499 newPoly->nY = nY; … … 523 535 524 536 newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D)); 537 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree); 525 538 newPoly->nW = nW; 526 539 newPoly->nX = nX; … … 561 574 } 562 575 563 void psDPolynomial1DFree(psDPolynomial1D *myPoly)576 static void dPolynomial1DFree(psDPolynomial1D *myPoly) 564 577 { 565 578 psFree(myPoly->coeff); 566 579 psFree(myPoly->coeffErr); 567 580 psFree(myPoly->mask); 568 psFree(myPoly); 569 } 570 571 void psDPolynomial2DFree(psDPolynomial2D *myPoly) 581 } 582 583 static void dPolynomial2DFree(psDPolynomial2D *myPoly) 572 584 { 573 585 int x = 0; … … 581 593 psFree(myPoly->coeffErr); 582 594 psFree(myPoly->mask); 583 584 psFree(myPoly); 585 } 586 587 void psDPolynomial3DFree(psDPolynomial3D *myPoly) 595 } 596 597 static void dPolynomial3DFree(psDPolynomial3D *myPoly) 588 598 { 589 599 int x = 0; … … 604 614 psFree(myPoly->coeffErr); 605 615 psFree(myPoly->mask); 606 psFree(myPoly); 607 } 608 609 void psDPolynomial4DFree(psDPolynomial4D *myPoly) 616 } 617 618 static void dPolynomial4DFree(psDPolynomial4D *myPoly) 610 619 { 611 620 int w = 0; … … 632 641 psFree(myPoly->coeffErr); 633 642 psFree(myPoly->mask); 634 psFree(myPoly);635 643 } 636 644 -
trunk/psLib/src/dataManip/psFunctions.h
r1020 r1073 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-06- 14 19:32:42$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 … … 104 104 ); 105 105 106 /** Destructor */107 void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy108 );109 110 /** Destructor */111 void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy112 );113 /** Destructor */114 void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy115 );116 /** Destructor */117 void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy118 );119 120 121 106 /** Evaluate 1D polynomial */ 122 107 float … … 206 191 ); 207 192 208 209 /** Destructor */210 void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy211 );212 /** Destructor */213 void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy214 );215 /** Destructor */216 void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy217 );218 /** Destructor */219 void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy220 );221 222 223 193 /** Evaluate 1D polynomial (double precision) */ 224 194 double -
trunk/psLib/src/dataManip/psStats.c
r1071 r1073 32 32 psStats *stats); 33 33 #endif 34 35 static void histogramFree(psHistogram *myHist); 34 36 35 37 /****************************************************************************** … … 68 70 69 71 /****************************************************************************** 70 psStatsFree(): This routine must free the psStats data structure.71 *****************************************************************************/72 void psStatsFree(psStats *stats)73 {74 psFree(stats);75 }76 77 /******************************************************************************78 72 psHistogramAlloc(lower, upper, n): allocate a uniform histogram structure 79 73 with the specifed upper and lower limits, and the specifed number of bins. … … 108 102 // bins, then there are N+1 bounds to those bins. 109 103 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 104 p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree); 110 105 newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32); 111 106 newHist->bounds->n = newHist->bounds->nalloc; … … 160 155 // Allocate memory for the new histogram structure. 161 156 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 157 p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree); 162 158 newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32); 163 159 newHist->bounds->n = newHist->bounds->nalloc; … … 182 178 } 183 179 184 void psHistogramFree(psHistogram *myHist) 185 { 186 psVectorFree(myHist->bounds); 187 psVectorFree(myHist->nums); 188 psFree(myHist); 180 static void histogramFree(psHistogram *myHist) 181 { 182 psFree(myHist->bounds); 183 psFree(myHist->nums); 189 184 } 190 185 … … 618 613 619 614 // Free temporary data buffers. 620 ps StatsFree(stats2);615 psFree(stats2); 621 616 622 617 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. … … 688 683 689 684 // Free the temporary data structures. 690 ps VectorFree(unsortedVector);691 ps VectorFree(sortedVector);685 psFree(unsortedVector); 686 psFree(sortedVector); 692 687 } 693 688 … … 775 770 776 771 // Free temporary data buffers. 777 ps StatsFree(stats2);772 psFree(stats2); 778 773 779 774 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. … … 840 835 841 836 // Free the temporary data structures. 842 ps VectorFree(unsortedVector);843 ps VectorFree(sortedVector);837 psFree(unsortedVector); 838 psFree(sortedVector); 844 839 // NOTE: This is the 845 840 } … … 1043 1038 } 1044 1039 1045 ps VectorFree(tmpMask);1040 psFree(tmpMask); 1046 1041 } 1047 1042 … … 1125 1120 stats->robustLQ = stats->clippedMean; 1126 1121 } 1127 ps StatsFree(tmpStats);1128 ps HistogramFree(robustHistogram);1122 psFree(tmpStats); 1123 psFree(robustHistogram); 1129 1124 return; 1130 1125 } … … 1200 1195 stats->robustNfit = 0.0; 1201 1196 stats->robustN50 = 0.0; 1202 ps StatsFree(tmpStats);1203 ps HistogramFree(robustHistogram);1197 psFree(tmpStats); 1198 psFree(robustHistogram); 1204 1199 } 1205 1200 -
trunk/psLib/src/dataManip/psStats.h
r1020 r1073 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06- 14 19:33:09$11 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-23 23:00:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 psStats *psStatsAlloc(psStatsOptions options); ///< Statistics to measure 89 89 90 /** A destructor for the stats structure.*/91 void psStatsFree(psStats *restrict stats); ///< Stats structure to destroy92 93 90 /****************************************************************************** 94 91 Histogram functions and data structures. … … 116 113 psHistogram * psHistogramAllocGeneric(const psVector *restrict bounds); ///< Bounds for the bins 117 114 118 119 /** Destructor \ingroup MathGroup **/120 void psHistogramFree(psHistogram *myHist); ///< Histogram to destroy121 122 123 115 /** Calculate a histogram \ingroup MathGroup **/ 124 116 psHistogram *psHistogramVector (psHistogram *out, ///< Histogram data -
trunk/psLib/src/dataManip/psVectorFFT.c
r1010 r1073 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-06- 12 02:17:25 $7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-06-23 23:00:15 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 /* got good image data? */ 36 36 if (in==NULL) { 37 ps ImageFree(out);37 psFree(out); 38 38 return NULL; 39 39 } … … 44 44 psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)", 45 45 type); 46 ps ImageFree(out);46 psFree(out); 47 47 return NULL; 48 48 } … … 51 51 psError(__func__,"Input image must be complex image for reverse FFT (type=%d).", 52 52 type); 53 ps ImageFree(out);53 psFree(out); 54 54 return NULL; 55 55 … … 76 76 if (plan == NULL) { 77 77 psError(__func__,"Failed to create FFTW plan."); 78 ps ImageFree(out);78 psFree(out); 79 79 return NULL; 80 80 } … … 98 98 99 99 if (in == NULL) { 100 ps ImageFree(out);100 psFree(out); 101 101 return NULL; 102 102 } … … 143 143 psError(__func__,"Can not extract real component from given image type (%d).", 144 144 type); 145 ps ImageFree(out);145 psFree(out); 146 146 return NULL; 147 147 } … … 158 158 159 159 if (in == NULL) { 160 ps ImageFree(out);160 psFree(out); 161 161 return NULL; 162 162 } … … 205 205 psError(__func__,"Can not extract imaginary component from given image type (%d).", 206 206 type); 207 ps ImageFree(out);207 psFree(out); 208 208 return NULL; 209 209 } … … 220 220 221 221 if (real == NULL || imag == NULL) { 222 ps ImageFree(out);222 psFree(out); 223 223 return NULL; 224 224 } … … 230 230 if (imag->type.type != type) { 231 231 psError(__func__,"The inputs to psImageComplex must be the same type."); 232 ps ImageFree(out);232 psFree(out); 233 233 return NULL; 234 234 } … … 237 237 imag->numRows != numRows) { 238 238 psError(__func__,"The inputs to psImageComplex must be the same dimensions."); 239 ps ImageFree(out);239 psFree(out); 240 240 return NULL; 241 241 } … … 243 243 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 244 244 psError(__func__,"The inputs to psImageComplex can not be complex."); 245 ps ImageFree(out);245 psFree(out); 246 246 return NULL; 247 247 } … … 249 249 if (type != PS_TYPE_F32 && type != PS_TYPE_F64) { 250 250 psError(__func__,"The input type to psImageComplex must be a floating point."); 251 ps ImageFree(out);251 psFree(out); 252 252 return NULL; 253 253 } … … 287 287 psError(__func__,"Can not merge real and imaginary portions for given image type (%d).", 288 288 type); 289 ps ImageFree(out);289 psFree(out); 290 290 return NULL; 291 291 } … … 302 302 303 303 if (in == NULL) { 304 ps ImageFree(out);304 psFree(out); 305 305 return NULL; 306 306 } … … 347 347 psError(__func__,"Can not compute complex conjugate for given image type (%d).", 348 348 type); 349 ps ImageFree(out);349 psFree(out); 350 350 return NULL; 351 351 } … … 362 362 363 363 if (in == NULL) { 364 ps ImageFree(out);364 psFree(out); 365 365 return NULL; 366 366 } … … 374 374 if (! PS_IS_PSELEMTYPE_COMPLEX(type)) { 375 375 psError(__func__,"Power Spectrum for non-complex inputs is not implemented."); 376 ps ImageFree(out);376 psFree(out); 377 377 return NULL; 378 378 } … … 417 417 psError(__func__,"Can not power spectrum for given image type (%d).", 418 418 type); 419 ps ImageFree(out);419 psFree(out); 420 420 return NULL; 421 421 } … … 435 435 /* got good image data? */ 436 436 if (in==NULL) { 437 ps VectorFree(out);437 psFree(out); 438 438 return NULL; 439 439 } … … 444 444 psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)", 445 445 type); 446 ps VectorFree(out);446 psFree(out); 447 447 return NULL; 448 448 } … … 451 451 psError(__func__,"Input image must be complex image for reverse FFT (type=%d).", 452 452 type); 453 ps VectorFree(out);453 psFree(out); 454 454 return NULL; 455 455 … … 491 491 if (plan == NULL) { 492 492 psError(__func__,"Failed to create FFTW plan."); 493 ps VectorFree(out);493 psFree(out); 494 494 return NULL; 495 495 } … … 510 510 511 511 if (in == NULL) { 512 ps VectorFree(out);512 psFree(out); 513 513 return NULL; 514 514 } … … 542 542 psError(__func__,"Can not extract real component from given vector type (%d).", 543 543 type); 544 ps VectorFree(out);544 psFree(out); 545 545 return NULL; 546 546 } … … 556 556 557 557 if (in == NULL) { 558 ps VectorFree(out);558 psFree(out); 559 559 return NULL; 560 560 } … … 588 588 psError(__func__,"Can not extract imaginary component from given vector type (%d).", 589 589 type); 590 ps VectorFree(out);590 psFree(out); 591 591 return NULL; 592 592 } … … 602 602 603 603 if (real == NULL || imag == NULL) { 604 ps VectorFree(out);604 psFree(out); 605 605 return NULL; 606 606 } … … 615 615 if (imag->type.type != type) { 616 616 psError(__func__,"The inputs to psVectorComplex must be the same type."); 617 ps VectorFree(out);617 psFree(out); 618 618 return NULL; 619 619 } … … 621 621 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 622 622 psError(__func__,"The inputs to psVectorComplex can not be complex."); 623 ps VectorFree(out);623 psFree(out); 624 624 return NULL; 625 625 } … … 640 640 psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).", 641 641 type); 642 ps VectorFree(out);642 psFree(out); 643 643 return NULL; 644 644 } … … 654 654 655 655 if (in == NULL) { 656 ps VectorFree(out);656 psFree(out); 657 657 return NULL; 658 658 } … … 687 687 psError(__func__,"Can not compute complex conjugate for given vector type (%d).", 688 688 type); 689 ps VectorFree(out);689 psFree(out); 690 690 return NULL; 691 691 } … … 703 703 704 704 if (in == NULL) { 705 ps VectorFree(out);705 psFree(out); 706 706 return NULL; 707 707 } … … 716 716 if (! PS_IS_PSELEMTYPE_COMPLEX(type)) { 717 717 psError(__func__,"Power Spectrum for non-complex inputs is not implemented."); 718 ps VectorFree(out);718 psFree(out); 719 719 return NULL; 720 720 } … … 747 747 psError(__func__,"Can not power spectrum for given vector type (%d).", 748 748 type); 749 ps VectorFree(out);750 return NULL; 751 } 752 753 return out; 754 755 } 749 psFree(out); 750 return NULL; 751 } 752 753 return out; 754 755 } -
trunk/psLib/src/fft/psVectorFFT.c
r1010 r1073 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-06- 12 02:17:25 $7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-06-23 23:00:15 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 /* got good image data? */ 36 36 if (in==NULL) { 37 ps ImageFree(out);37 psFree(out); 38 38 return NULL; 39 39 } … … 44 44 psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)", 45 45 type); 46 ps ImageFree(out);46 psFree(out); 47 47 return NULL; 48 48 } … … 51 51 psError(__func__,"Input image must be complex image for reverse FFT (type=%d).", 52 52 type); 53 ps ImageFree(out);53 psFree(out); 54 54 return NULL; 55 55 … … 76 76 if (plan == NULL) { 77 77 psError(__func__,"Failed to create FFTW plan."); 78 ps ImageFree(out);78 psFree(out); 79 79 return NULL; 80 80 } … … 98 98 99 99 if (in == NULL) { 100 ps ImageFree(out);100 psFree(out); 101 101 return NULL; 102 102 } … … 143 143 psError(__func__,"Can not extract real component from given image type (%d).", 144 144 type); 145 ps ImageFree(out);145 psFree(out); 146 146 return NULL; 147 147 } … … 158 158 159 159 if (in == NULL) { 160 ps ImageFree(out);160 psFree(out); 161 161 return NULL; 162 162 } … … 205 205 psError(__func__,"Can not extract imaginary component from given image type (%d).", 206 206 type); 207 ps ImageFree(out);207 psFree(out); 208 208 return NULL; 209 209 } … … 220 220 221 221 if (real == NULL || imag == NULL) { 222 ps ImageFree(out);222 psFree(out); 223 223 return NULL; 224 224 } … … 230 230 if (imag->type.type != type) { 231 231 psError(__func__,"The inputs to psImageComplex must be the same type."); 232 ps ImageFree(out);232 psFree(out); 233 233 return NULL; 234 234 } … … 237 237 imag->numRows != numRows) { 238 238 psError(__func__,"The inputs to psImageComplex must be the same dimensions."); 239 ps ImageFree(out);239 psFree(out); 240 240 return NULL; 241 241 } … … 243 243 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 244 244 psError(__func__,"The inputs to psImageComplex can not be complex."); 245 ps ImageFree(out);245 psFree(out); 246 246 return NULL; 247 247 } … … 249 249 if (type != PS_TYPE_F32 && type != PS_TYPE_F64) { 250 250 psError(__func__,"The input type to psImageComplex must be a floating point."); 251 ps ImageFree(out);251 psFree(out); 252 252 return NULL; 253 253 } … … 287 287 psError(__func__,"Can not merge real and imaginary portions for given image type (%d).", 288 288 type); 289 ps ImageFree(out);289 psFree(out); 290 290 return NULL; 291 291 } … … 302 302 303 303 if (in == NULL) { 304 ps ImageFree(out);304 psFree(out); 305 305 return NULL; 306 306 } … … 347 347 psError(__func__,"Can not compute complex conjugate for given image type (%d).", 348 348 type); 349 ps ImageFree(out);349 psFree(out); 350 350 return NULL; 351 351 } … … 362 362 363 363 if (in == NULL) { 364 ps ImageFree(out);364 psFree(out); 365 365 return NULL; 366 366 } … … 374 374 if (! PS_IS_PSELEMTYPE_COMPLEX(type)) { 375 375 psError(__func__,"Power Spectrum for non-complex inputs is not implemented."); 376 ps ImageFree(out);376 psFree(out); 377 377 return NULL; 378 378 } … … 417 417 psError(__func__,"Can not power spectrum for given image type (%d).", 418 418 type); 419 ps ImageFree(out);419 psFree(out); 420 420 return NULL; 421 421 } … … 435 435 /* got good image data? */ 436 436 if (in==NULL) { 437 ps VectorFree(out);437 psFree(out); 438 438 return NULL; 439 439 } … … 444 444 psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)", 445 445 type); 446 ps VectorFree(out);446 psFree(out); 447 447 return NULL; 448 448 } … … 451 451 psError(__func__,"Input image must be complex image for reverse FFT (type=%d).", 452 452 type); 453 ps VectorFree(out);453 psFree(out); 454 454 return NULL; 455 455 … … 491 491 if (plan == NULL) { 492 492 psError(__func__,"Failed to create FFTW plan."); 493 ps VectorFree(out);493 psFree(out); 494 494 return NULL; 495 495 } … … 510 510 511 511 if (in == NULL) { 512 ps VectorFree(out);512 psFree(out); 513 513 return NULL; 514 514 } … … 542 542 psError(__func__,"Can not extract real component from given vector type (%d).", 543 543 type); 544 ps VectorFree(out);544 psFree(out); 545 545 return NULL; 546 546 } … … 556 556 557 557 if (in == NULL) { 558 ps VectorFree(out);558 psFree(out); 559 559 return NULL; 560 560 } … … 588 588 psError(__func__,"Can not extract imaginary component from given vector type (%d).", 589 589 type); 590 ps VectorFree(out);590 psFree(out); 591 591 return NULL; 592 592 } … … 602 602 603 603 if (real == NULL || imag == NULL) { 604 ps VectorFree(out);604 psFree(out); 605 605 return NULL; 606 606 } … … 615 615 if (imag->type.type != type) { 616 616 psError(__func__,"The inputs to psVectorComplex must be the same type."); 617 ps VectorFree(out);617 psFree(out); 618 618 return NULL; 619 619 } … … 621 621 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 622 622 psError(__func__,"The inputs to psVectorComplex can not be complex."); 623 ps VectorFree(out);623 psFree(out); 624 624 return NULL; 625 625 } … … 640 640 psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).", 641 641 type); 642 ps VectorFree(out);642 psFree(out); 643 643 return NULL; 644 644 } … … 654 654 655 655 if (in == NULL) { 656 ps VectorFree(out);656 psFree(out); 657 657 return NULL; 658 658 } … … 687 687 psError(__func__,"Can not compute complex conjugate for given vector type (%d).", 688 688 type); 689 ps VectorFree(out);689 psFree(out); 690 690 return NULL; 691 691 } … … 703 703 704 704 if (in == NULL) { 705 ps VectorFree(out);705 psFree(out); 706 706 return NULL; 707 707 } … … 716 716 if (! PS_IS_PSELEMTYPE_COMPLEX(type)) { 717 717 psError(__func__,"Power Spectrum for non-complex inputs is not implemented."); 718 ps VectorFree(out);718 psFree(out); 719 719 return NULL; 720 720 } … … 747 747 psError(__func__,"Can not power spectrum for given vector type (%d).", 748 748 type); 749 ps VectorFree(out);750 return NULL; 751 } 752 753 return out; 754 755 } 749 psFree(out); 750 return NULL; 751 } 752 753 return out; 754 755 } -
trunk/psLib/src/image/psImage.c
r996 r1073 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06- 11 02:02:53$11 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-23 23:00:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "psImage.h" 29 29 30 static void imageFree(psImage* image); 30 31 31 32 /*****************************************************************************/ … … 49 50 50 51 psImage *image = (psImage *)psAlloc(sizeof(psImage)); 52 p_psMemSetDeallocator(image,(psFreeFcn)imageFree); 51 53 52 54 image->data.V = psAlloc(sizeof(void*)*numRows); … … 71 73 } 72 74 73 void psImageFree(psImage *image)75 static void imageFree(psImage* image) 74 76 { 75 77 if (image == NULL) { … … 96 98 psFree(image->data.V); 97 99 image->data.V = NULL; 98 99 psFree(image);100 100 } 101 101 … … 237 237 if (children[i] != NULL) { 238 238 numFreed++; 239 ps ImageFree(children[i]);239 psFree(children[i]); 240 240 } 241 241 } … … 341 341 case PS_TYPE_PTR: \ 342 342 psError(__func__,"Can't copy image from a matrix of pointers."); \ 343 ps ImageFree(output); \343 psFree(output); \ 344 344 return NULL; \ 345 345 default: \ … … 391 391 case PS_TYPE_PTR: 392 392 psError(__func__,"Can't copy image into a matrix of pointers."); 393 ps ImageFree(output);393 psFree(output); 394 394 return NULL; 395 395 } … … 534 534 case PS_TYPE_PTR: 535 535 psError (__func__, "Can't copy image from a matrix of pointers."); 536 ps ImageFree (output);536 psFree (output); 537 537 return ((void *) 0); 538 538 default: … … 676 676 case PS_TYPE_PTR: 677 677 psError (__func__, "Can't copy image from a matrix of pointers."); 678 ps ImageFree (output);678 psFree (output); 679 679 return ((void *) 0); 680 680 default: … … 818 818 case PS_TYPE_PTR: 819 819 psError (__func__, "Can't copy image from a matrix of pointers."); 820 ps ImageFree (output);820 psFree (output); 821 821 return ((void *) 0); 822 822 default: … … 960 960 case PS_TYPE_PTR: 961 961 psError (__func__, "Can't copy image from a matrix of pointers."); 962 ps ImageFree (output);962 psFree (output); 963 963 return ((void *) 0); 964 964 default: … … 1102 1102 case PS_TYPE_PTR: 1103 1103 psError (__func__, "Can't copy image from a matrix of pointers."); 1104 ps ImageFree (output);1104 psFree (output); 1105 1105 return ((void *) 0); 1106 1106 default: … … 1244 1244 case PS_TYPE_PTR: 1245 1245 psError (__func__, "Can't copy image from a matrix of pointers."); 1246 ps ImageFree (output);1246 psFree (output); 1247 1247 return ((void *) 0); 1248 1248 default: … … 1386 1386 case PS_TYPE_PTR: 1387 1387 psError (__func__, "Can't copy image from a matrix of pointers."); 1388 ps ImageFree (output);1388 psFree (output); 1389 1389 return ((void *) 0); 1390 1390 default: … … 1528 1528 case PS_TYPE_PTR: 1529 1529 psError (__func__, "Can't copy image from a matrix of pointers."); 1530 ps ImageFree (output);1530 psFree (output); 1531 1531 return ((void *) 0); 1532 1532 default: … … 1670 1670 case PS_TYPE_PTR: 1671 1671 psError (__func__, "Can't copy image from a matrix of pointers."); 1672 ps ImageFree (output);1672 psFree (output); 1673 1673 return ((void *) 0); 1674 1674 default: … … 1812 1812 case PS_TYPE_PTR: 1813 1813 psError (__func__, "Can't copy image from a matrix of pointers."); 1814 ps ImageFree (output);1814 psFree (output); 1815 1815 return ((void *) 0); 1816 1816 default: … … 1954 1954 case PS_TYPE_PTR: 1955 1955 psError (__func__, "Can't copy image from a matrix of pointers."); 1956 ps ImageFree (output);1956 psFree (output); 1957 1957 return ((void *) 0); 1958 1958 default: … … 2096 2096 case PS_TYPE_PTR: 2097 2097 psError (__func__, "Can't copy image from a matrix of pointers."); 2098 ps ImageFree (output);2098 psFree (output); 2099 2099 return ((void *) 0); 2100 2100 default: … … 2104 2104 case PS_TYPE_PTR: 2105 2105 psError (__func__, "Can't copy image into a matrix of pointers."); 2106 ps ImageFree (output);2106 psFree (output); 2107 2107 return ((void *) 0); 2108 2108 } -
trunk/psLib/src/image/psImage.h
r974 r1073 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-06- 10 01:58:06$13 * @version $Revision: 1.22 $ $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 … … 110 110 ); 111 111 112 /** Destroy the specified image.113 *114 * Uses psLib memory deallocation functions to free an image and any existing115 * children.116 *117 */118 void psImageFree(119 psImage *restrict image ///< Free psImage120 );121 122 112 /** Frees all children of a psImage. 123 113 * -
trunk/psLib/src/image/psImageIO.c
r997 r1073 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-06- 11 03:45:07$9 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-06-23 23:00:15 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 #include "psImageIO.h" 20 20 #include "psError.h" 21 #include "psMemory.h" 21 22 22 23 psImage* psImageReadSection(psImage* output, int col, int row, int numCols, … … 39 40 if (filename == NULL) { 40 41 psError(__func__,"Must specify filename; it can not be NULL."); 41 ps ImageFree(output);42 psFree(output); 42 43 return NULL; 43 44 } … … 49 50 psError(__func__,"Could not open file '%s'. (%s)", 50 51 filename, fitsErr); 51 ps ImageFree(output);52 psFree(output); 52 53 return NULL; 53 54 } … … 61 62 psError(__func__,"Could not index to '%s' HDU for file %s. (%s)", 62 63 extname, filename, fitsErr); 63 ps ImageFree(output);64 psFree(output); 64 65 return NULL; 65 66 } … … 71 72 psError(__func__,"Could not index to HDU #%d for file %s. (%s)", 72 73 extnum, filename, fitsErr); 73 ps ImageFree(output);74 psFree(output); 74 75 return NULL; 75 76 } … … 83 84 psError("Could not determine image data type of '%s'. (%s)", 84 85 filename, fitsErr); 85 ps ImageFree(output);86 psFree(output); 86 87 return NULL; 87 88 } … … 94 95 psError("Could not determine dimensions of '%s'. (%s)", 95 96 filename,fitsErr); 96 ps ImageFree(output);97 psFree(output); 97 98 return NULL; 98 99 } … … 104 105 psError("Dimensions of '%s' are not supported (NAXIS=%i).", 105 106 filename, nAxis); 106 ps ImageFree(output);107 psFree(output); 107 108 return NULL; 108 109 } … … 115 116 psError("Could not determine image size of '%s'. (%s)", 116 117 filename,fitsErr); 117 ps ImageFree(output);118 psFree(output); 118 119 return NULL; 119 120 } … … 181 182 psError(__func__,"Unsupported bitpix value (%d) in FITS file %s.", 182 183 bitPix,filename); 183 ps ImageFree(output);184 psFree(output); 184 185 return NULL; 185 186 } … … 187 188 if (fits_read_subset(fptr, fitsDatatype, firstPixel, lastPixel, increment, 188 189 NULL, output->data.V[0], &anynull, &status) != 0) { 189 ps ImageFree(output);190 psFree(output); 190 191 (void)fits_get_errstatus(status, fitsErr); 191 192 status = 0; -
trunk/psLib/src/image/psImageIO.d
r986 r1073 1 1 psImageIO.o psImageIO.d : psImageIO.c psImageIO.h ../collections/psImage.h \ 2 ../collections/psType.h ../sysUtils/psError.h 2 ../collections/psType.h ../sysUtils/psError.h ../sysUtils/psMemory.h -
trunk/psLib/src/image/psImageStats.c
r1072 r1073 67 67 68 68 stats = psVectorStats(stats, junkData, junkMask, maskVal); 69 ps VectorFree(junkMask);69 psFree(junkMask); 70 70 } else { 71 71 stats = psVectorStats(stats, junkData, NULL, 0); 72 72 } 73 ps VectorFree(junkData);73 psFree(junkData); 74 74 return(stats); 75 75 } … … 129 129 } 130 130 out = psHistogramVector(out, junkData, junkMask, maskVal); 131 ps VectorFree(junkMask);131 psFree(junkMask); 132 132 } else { 133 133 out = psHistogramVector(out, junkData, NULL, 0); 134 134 } 135 ps VectorFree(junkData);135 psFree(junkData); 136 136 137 137 return(out); … … 339 339 // Free the Chebyshev polynomials that were created in this routine. 340 340 for (i=0;i<maxChebyPoly;i++) { 341 ps Polynomial1DFree(chebPolys[i]);341 psFree(chebPolys[i]); 342 342 } 343 343 psFree(chebPolys); … … 413 413 // Free the Chebyshev polynomials that were created in this routine. 414 414 for (i=0;i<maxChebyPoly;i++) { 415 ps Polynomial1DFree(chebPolys[i]);415 psFree(chebPolys[i]); 416 416 } 417 417 psFree(chebPolys); -
trunk/psLib/src/imageops/psImageStats.c
r1072 r1073 67 67 68 68 stats = psVectorStats(stats, junkData, junkMask, maskVal); 69 ps VectorFree(junkMask);69 psFree(junkMask); 70 70 } else { 71 71 stats = psVectorStats(stats, junkData, NULL, 0); 72 72 } 73 ps VectorFree(junkData);73 psFree(junkData); 74 74 return(stats); 75 75 } … … 129 129 } 130 130 out = psHistogramVector(out, junkData, junkMask, maskVal); 131 ps VectorFree(junkMask);131 psFree(junkMask); 132 132 } else { 133 133 out = psHistogramVector(out, junkData, NULL, 0); 134 134 } 135 ps VectorFree(junkData);135 psFree(junkData); 136 136 137 137 return(out); … … 339 339 // Free the Chebyshev polynomials that were created in this routine. 340 340 for (i=0;i<maxChebyPoly;i++) { 341 ps Polynomial1DFree(chebPolys[i]);341 psFree(chebPolys[i]); 342 342 } 343 343 psFree(chebPolys); … … 413 413 // Free the Chebyshev polynomials that were created in this routine. 414 414 for (i=0;i<maxChebyPoly;i++) { 415 ps Polynomial1DFree(chebPolys[i]);415 psFree(chebPolys[i]); 416 416 } 417 417 psFree(chebPolys); -
trunk/psLib/src/math/psPolynomial.c
r1022 r1073 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-06- 14 19:40:14$9 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-06-23 23:00:15 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 #include <gsl/gsl_rng.h> 35 35 #include <gsl/gsl_randist.h> 36 37 static void polynomial1DFree(psPolynomial1D *myPoly); 38 static void polynomial2DFree(psPolynomial2D *myPoly); 39 static void polynomial3DFree(psPolynomial3D *myPoly); 40 static void polynomial4DFree(psPolynomial4D *myPoly); 41 static void dPolynomial1DFree(psDPolynomial1D *myPoly); 42 static void dPolynomial2DFree(psDPolynomial2D *myPoly); 43 static void dPolynomial3DFree(psDPolynomial3D *myPoly); 44 static void dPolynomial4DFree(psDPolynomial4D *myPoly); 45 36 46 /*****************************************************************************/ 37 47 /* FUNCTION IMPLEMENTATION - PUBLIC */ … … 108 118 109 119 newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D)); 120 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree); 110 121 newPoly->n = n; 111 122 newPoly->coeff = (float *) psAlloc(n * sizeof(float)); … … 128 139 129 140 newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D)); 141 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree); 130 142 newPoly->nX = nX; 131 143 newPoly->nY = nY; … … 158 170 159 171 newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D)); 172 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree); 160 173 newPoly->nX = nX; 161 174 newPoly->nY = nY; … … 197 210 198 211 newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D)); 212 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree); 199 213 newPoly->nW = nW; 200 214 newPoly->nX = nX; … … 235 249 } 236 250 237 void psPolynomial1DFree(psPolynomial1D *myPoly)251 static void polynomial1DFree(psPolynomial1D *myPoly) 238 252 { 239 253 psFree(myPoly->coeff); 240 254 psFree(myPoly->coeffErr); 241 255 psFree(myPoly->mask); 242 psFree(myPoly); 243 } 244 245 void psPolynomial2DFree(psPolynomial2D *myPoly) 256 } 257 258 static void polynomial2DFree(psPolynomial2D *myPoly) 246 259 { 247 260 int x = 0; … … 255 268 psFree(myPoly->coeffErr); 256 269 psFree(myPoly->mask); 257 258 psFree(myPoly); 259 } 260 261 void psPolynomial3DFree(psPolynomial3D *myPoly) 270 } 271 272 static void polynomial3DFree(psPolynomial3D *myPoly) 262 273 { 263 274 int x = 0; … … 278 289 psFree(myPoly->coeffErr); 279 290 psFree(myPoly->mask); 280 psFree(myPoly); 281 } 282 283 void psPolynomial4DFree(psPolynomial4D *myPoly) 291 } 292 293 static void polynomial4DFree(psPolynomial4D *myPoly) 284 294 { 285 295 int w = 0; … … 306 316 psFree(myPoly->coeffErr); 307 317 psFree(myPoly->mask); 308 psFree(myPoly);309 318 } 310 319 … … 434 443 435 444 newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D)); 445 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree); 436 446 newPoly->n = n; 437 447 newPoly->coeff = (double *) psAlloc(n * sizeof(double)); … … 454 464 455 465 newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D)); 466 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree); 456 467 newPoly->nX = nX; 457 468 newPoly->nY = nY; … … 484 495 485 496 newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D)); 497 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree); 486 498 newPoly->nX = nX; 487 499 newPoly->nY = nY; … … 523 535 524 536 newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D)); 537 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree); 525 538 newPoly->nW = nW; 526 539 newPoly->nX = nX; … … 561 574 } 562 575 563 void psDPolynomial1DFree(psDPolynomial1D *myPoly)576 static void dPolynomial1DFree(psDPolynomial1D *myPoly) 564 577 { 565 578 psFree(myPoly->coeff); 566 579 psFree(myPoly->coeffErr); 567 580 psFree(myPoly->mask); 568 psFree(myPoly); 569 } 570 571 void psDPolynomial2DFree(psDPolynomial2D *myPoly) 581 } 582 583 static void dPolynomial2DFree(psDPolynomial2D *myPoly) 572 584 { 573 585 int x = 0; … … 581 593 psFree(myPoly->coeffErr); 582 594 psFree(myPoly->mask); 583 584 psFree(myPoly); 585 } 586 587 void psDPolynomial3DFree(psDPolynomial3D *myPoly) 595 } 596 597 static void dPolynomial3DFree(psDPolynomial3D *myPoly) 588 598 { 589 599 int x = 0; … … 604 614 psFree(myPoly->coeffErr); 605 615 psFree(myPoly->mask); 606 psFree(myPoly); 607 } 608 609 void psDPolynomial4DFree(psDPolynomial4D *myPoly) 616 } 617 618 static void dPolynomial4DFree(psDPolynomial4D *myPoly) 610 619 { 611 620 int w = 0; … … 632 641 psFree(myPoly->coeffErr); 633 642 psFree(myPoly->mask); 634 psFree(myPoly);635 643 } 636 644 -
trunk/psLib/src/math/psPolynomial.h
r1020 r1073 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-06- 14 19:32:42$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 … … 104 104 ); 105 105 106 /** Destructor */107 void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy108 );109 110 /** Destructor */111 void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy112 );113 /** Destructor */114 void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy115 );116 /** Destructor */117 void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy118 );119 120 121 106 /** Evaluate 1D polynomial */ 122 107 float … … 206 191 ); 207 192 208 209 /** Destructor */210 void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy211 );212 /** Destructor */213 void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy214 );215 /** Destructor */216 void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy217 );218 /** Destructor */219 void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy220 );221 222 223 193 /** Evaluate 1D polynomial (double precision) */ 224 194 double -
trunk/psLib/src/math/psSpline.c
r1022 r1073 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-06- 14 19:40:14$9 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-06-23 23:00:15 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 #include <gsl/gsl_rng.h> 35 35 #include <gsl/gsl_randist.h> 36 37 static void polynomial1DFree(psPolynomial1D *myPoly); 38 static void polynomial2DFree(psPolynomial2D *myPoly); 39 static void polynomial3DFree(psPolynomial3D *myPoly); 40 static void polynomial4DFree(psPolynomial4D *myPoly); 41 static void dPolynomial1DFree(psDPolynomial1D *myPoly); 42 static void dPolynomial2DFree(psDPolynomial2D *myPoly); 43 static void dPolynomial3DFree(psDPolynomial3D *myPoly); 44 static void dPolynomial4DFree(psDPolynomial4D *myPoly); 45 36 46 /*****************************************************************************/ 37 47 /* FUNCTION IMPLEMENTATION - PUBLIC */ … … 108 118 109 119 newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D)); 120 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree); 110 121 newPoly->n = n; 111 122 newPoly->coeff = (float *) psAlloc(n * sizeof(float)); … … 128 139 129 140 newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D)); 141 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree); 130 142 newPoly->nX = nX; 131 143 newPoly->nY = nY; … … 158 170 159 171 newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D)); 172 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree); 160 173 newPoly->nX = nX; 161 174 newPoly->nY = nY; … … 197 210 198 211 newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D)); 212 p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree); 199 213 newPoly->nW = nW; 200 214 newPoly->nX = nX; … … 235 249 } 236 250 237 void psPolynomial1DFree(psPolynomial1D *myPoly)251 static void polynomial1DFree(psPolynomial1D *myPoly) 238 252 { 239 253 psFree(myPoly->coeff); 240 254 psFree(myPoly->coeffErr); 241 255 psFree(myPoly->mask); 242 psFree(myPoly); 243 } 244 245 void psPolynomial2DFree(psPolynomial2D *myPoly) 256 } 257 258 static void polynomial2DFree(psPolynomial2D *myPoly) 246 259 { 247 260 int x = 0; … … 255 268 psFree(myPoly->coeffErr); 256 269 psFree(myPoly->mask); 257 258 psFree(myPoly); 259 } 260 261 void psPolynomial3DFree(psPolynomial3D *myPoly) 270 } 271 272 static void polynomial3DFree(psPolynomial3D *myPoly) 262 273 { 263 274 int x = 0; … … 278 289 psFree(myPoly->coeffErr); 279 290 psFree(myPoly->mask); 280 psFree(myPoly); 281 } 282 283 void psPolynomial4DFree(psPolynomial4D *myPoly) 291 } 292 293 static void polynomial4DFree(psPolynomial4D *myPoly) 284 294 { 285 295 int w = 0; … … 306 316 psFree(myPoly->coeffErr); 307 317 psFree(myPoly->mask); 308 psFree(myPoly);309 318 } 310 319 … … 434 443 435 444 newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D)); 445 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree); 436 446 newPoly->n = n; 437 447 newPoly->coeff = (double *) psAlloc(n * sizeof(double)); … … 454 464 455 465 newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D)); 466 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree); 456 467 newPoly->nX = nX; 457 468 newPoly->nY = nY; … … 484 495 485 496 newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D)); 497 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree); 486 498 newPoly->nX = nX; 487 499 newPoly->nY = nY; … … 523 535 524 536 newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D)); 537 p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree); 525 538 newPoly->nW = nW; 526 539 newPoly->nX = nX; … … 561 574 } 562 575 563 void psDPolynomial1DFree(psDPolynomial1D *myPoly)576 static void dPolynomial1DFree(psDPolynomial1D *myPoly) 564 577 { 565 578 psFree(myPoly->coeff); 566 579 psFree(myPoly->coeffErr); 567 580 psFree(myPoly->mask); 568 psFree(myPoly); 569 } 570 571 void psDPolynomial2DFree(psDPolynomial2D *myPoly) 581 } 582 583 static void dPolynomial2DFree(psDPolynomial2D *myPoly) 572 584 { 573 585 int x = 0; … … 581 593 psFree(myPoly->coeffErr); 582 594 psFree(myPoly->mask); 583 584 psFree(myPoly); 585 } 586 587 void psDPolynomial3DFree(psDPolynomial3D *myPoly) 595 } 596 597 static void dPolynomial3DFree(psDPolynomial3D *myPoly) 588 598 { 589 599 int x = 0; … … 604 614 psFree(myPoly->coeffErr); 605 615 psFree(myPoly->mask); 606 psFree(myPoly); 607 } 608 609 void psDPolynomial4DFree(psDPolynomial4D *myPoly) 616 } 617 618 static void dPolynomial4DFree(psDPolynomial4D *myPoly) 610 619 { 611 620 int w = 0; … … 632 641 psFree(myPoly->coeffErr); 633 642 psFree(myPoly->mask); 634 psFree(myPoly);635 643 } 636 644 -
trunk/psLib/src/math/psSpline.h
r1020 r1073 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-06- 14 19:32:42$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 … … 104 104 ); 105 105 106 /** Destructor */107 void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy108 );109 110 /** Destructor */111 void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy112 );113 /** Destructor */114 void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy115 );116 /** Destructor */117 void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy118 );119 120 121 106 /** Evaluate 1D polynomial */ 122 107 float … … 206 191 ); 207 192 208 209 /** Destructor */210 void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy211 );212 /** Destructor */213 void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy214 );215 /** Destructor */216 void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy217 );218 /** Destructor */219 void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy220 );221 222 223 193 /** Evaluate 1D polynomial (double precision) */ 224 194 double -
trunk/psLib/src/math/psStats.c
r1071 r1073 32 32 psStats *stats); 33 33 #endif 34 35 static void histogramFree(psHistogram *myHist); 34 36 35 37 /****************************************************************************** … … 68 70 69 71 /****************************************************************************** 70 psStatsFree(): This routine must free the psStats data structure.71 *****************************************************************************/72 void psStatsFree(psStats *stats)73 {74 psFree(stats);75 }76 77 /******************************************************************************78 72 psHistogramAlloc(lower, upper, n): allocate a uniform histogram structure 79 73 with the specifed upper and lower limits, and the specifed number of bins. … … 108 102 // bins, then there are N+1 bounds to those bins. 109 103 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 104 p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree); 110 105 newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32); 111 106 newHist->bounds->n = newHist->bounds->nalloc; … … 160 155 // Allocate memory for the new histogram structure. 161 156 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 157 p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree); 162 158 newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32); 163 159 newHist->bounds->n = newHist->bounds->nalloc; … … 182 178 } 183 179 184 void psHistogramFree(psHistogram *myHist) 185 { 186 psVectorFree(myHist->bounds); 187 psVectorFree(myHist->nums); 188 psFree(myHist); 180 static void histogramFree(psHistogram *myHist) 181 { 182 psFree(myHist->bounds); 183 psFree(myHist->nums); 189 184 } 190 185 … … 618 613 619 614 // Free temporary data buffers. 620 ps StatsFree(stats2);615 psFree(stats2); 621 616 622 617 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. … … 688 683 689 684 // Free the temporary data structures. 690 ps VectorFree(unsortedVector);691 ps VectorFree(sortedVector);685 psFree(unsortedVector); 686 psFree(sortedVector); 692 687 } 693 688 … … 775 770 776 771 // Free temporary data buffers. 777 ps StatsFree(stats2);772 psFree(stats2); 778 773 779 774 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. … … 840 835 841 836 // Free the temporary data structures. 842 ps VectorFree(unsortedVector);843 ps VectorFree(sortedVector);837 psFree(unsortedVector); 838 psFree(sortedVector); 844 839 // NOTE: This is the 845 840 } … … 1043 1038 } 1044 1039 1045 ps VectorFree(tmpMask);1040 psFree(tmpMask); 1046 1041 } 1047 1042 … … 1125 1120 stats->robustLQ = stats->clippedMean; 1126 1121 } 1127 ps StatsFree(tmpStats);1128 ps HistogramFree(robustHistogram);1122 psFree(tmpStats); 1123 psFree(robustHistogram); 1129 1124 return; 1130 1125 } … … 1200 1195 stats->robustNfit = 0.0; 1201 1196 stats->robustN50 = 0.0; 1202 ps StatsFree(tmpStats);1203 ps HistogramFree(robustHistogram);1197 psFree(tmpStats); 1198 psFree(robustHistogram); 1204 1199 } 1205 1200 -
trunk/psLib/src/math/psStats.h
r1020 r1073 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06- 14 19:33:09$11 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-23 23:00:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 psStats *psStatsAlloc(psStatsOptions options); ///< Statistics to measure 89 89 90 /** A destructor for the stats structure.*/91 void psStatsFree(psStats *restrict stats); ///< Stats structure to destroy92 93 90 /****************************************************************************** 94 91 Histogram functions and data structures. … … 116 113 psHistogram * psHistogramAllocGeneric(const psVector *restrict bounds); ///< Bounds for the bins 117 114 118 119 /** Destructor \ingroup MathGroup **/120 void psHistogramFree(psHistogram *myHist); ///< Histogram to destroy121 122 123 115 /** Calculate a histogram \ingroup MathGroup **/ 124 116 psHistogram *psHistogramVector (psHistogram *out, ///< Histogram data -
trunk/psLib/src/mathtypes/psImage.c
r996 r1073 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06- 11 02:02:53$11 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-23 23:00:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "psImage.h" 29 29 30 static void imageFree(psImage* image); 30 31 31 32 /*****************************************************************************/ … … 49 50 50 51 psImage *image = (psImage *)psAlloc(sizeof(psImage)); 52 p_psMemSetDeallocator(image,(psFreeFcn)imageFree); 51 53 52 54 image->data.V = psAlloc(sizeof(void*)*numRows); … … 71 73 } 72 74 73 void psImageFree(psImage *image)75 static void imageFree(psImage* image) 74 76 { 75 77 if (image == NULL) { … … 96 98 psFree(image->data.V); 97 99 image->data.V = NULL; 98 99 psFree(image);100 100 } 101 101 … … 237 237 if (children[i] != NULL) { 238 238 numFreed++; 239 ps ImageFree(children[i]);239 psFree(children[i]); 240 240 } 241 241 } … … 341 341 case PS_TYPE_PTR: \ 342 342 psError(__func__,"Can't copy image from a matrix of pointers."); \ 343 ps ImageFree(output); \343 psFree(output); \ 344 344 return NULL; \ 345 345 default: \ … … 391 391 case PS_TYPE_PTR: 392 392 psError(__func__,"Can't copy image into a matrix of pointers."); 393 ps ImageFree(output);393 psFree(output); 394 394 return NULL; 395 395 } … … 534 534 case PS_TYPE_PTR: 535 535 psError (__func__, "Can't copy image from a matrix of pointers."); 536 ps ImageFree (output);536 psFree (output); 537 537 return ((void *) 0); 538 538 default: … … 676 676 case PS_TYPE_PTR: 677 677 psError (__func__, "Can't copy image from a matrix of pointers."); 678 ps ImageFree (output);678 psFree (output); 679 679 return ((void *) 0); 680 680 default: … … 818 818 case PS_TYPE_PTR: 819 819 psError (__func__, "Can't copy image from a matrix of pointers."); 820 ps ImageFree (output);820 psFree (output); 821 821 return ((void *) 0); 822 822 default: … … 960 960 case PS_TYPE_PTR: 961 961 psError (__func__, "Can't copy image from a matrix of pointers."); 962 ps ImageFree (output);962 psFree (output); 963 963 return ((void *) 0); 964 964 default: … … 1102 1102 case PS_TYPE_PTR: 1103 1103 psError (__func__, "Can't copy image from a matrix of pointers."); 1104 ps ImageFree (output);1104 psFree (output); 1105 1105 return ((void *) 0); 1106 1106 default: … … 1244 1244 case PS_TYPE_PTR: 1245 1245 psError (__func__, "Can't copy image from a matrix of pointers."); 1246 ps ImageFree (output);1246 psFree (output); 1247 1247 return ((void *) 0); 1248 1248 default: … … 1386 1386 case PS_TYPE_PTR: 1387 1387 psError (__func__, "Can't copy image from a matrix of pointers."); 1388 ps ImageFree (output);1388 psFree (output); 1389 1389 return ((void *) 0); 1390 1390 default: … … 1528 1528 case PS_TYPE_PTR: 1529 1529 psError (__func__, "Can't copy image from a matrix of pointers."); 1530 ps ImageFree (output);1530 psFree (output); 1531 1531 return ((void *) 0); 1532 1532 default: … … 1670 1670 case PS_TYPE_PTR: 1671 1671 psError (__func__, "Can't copy image from a matrix of pointers."); 1672 ps ImageFree (output);1672 psFree (output); 1673 1673 return ((void *) 0); 1674 1674 default: … … 1812 1812 case PS_TYPE_PTR: 1813 1813 psError (__func__, "Can't copy image from a matrix of pointers."); 1814 ps ImageFree (output);1814 psFree (output); 1815 1815 return ((void *) 0); 1816 1816 default: … … 1954 1954 case PS_TYPE_PTR: 1955 1955 psError (__func__, "Can't copy image from a matrix of pointers."); 1956 ps ImageFree (output);1956 psFree (output); 1957 1957 return ((void *) 0); 1958 1958 default: … … 2096 2096 case PS_TYPE_PTR: 2097 2097 psError (__func__, "Can't copy image from a matrix of pointers."); 2098 ps ImageFree (output);2098 psFree (output); 2099 2099 return ((void *) 0); 2100 2100 default: … … 2104 2104 case PS_TYPE_PTR: 2105 2105 psError (__func__, "Can't copy image into a matrix of pointers."); 2106 ps ImageFree (output);2106 psFree (output); 2107 2107 return ((void *) 0); 2108 2108 } -
trunk/psLib/src/mathtypes/psImage.h
r974 r1073 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-06- 10 01:58:06$13 * @version $Revision: 1.22 $ $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 … … 110 110 ); 111 111 112 /** Destroy the specified image.113 *114 * Uses psLib memory deallocation functions to free an image and any existing115 * children.116 *117 */118 void psImageFree(119 psImage *restrict image ///< Free psImage120 );121 122 112 /** Frees all children of a psImage. 123 113 * -
trunk/psLib/src/mathtypes/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/mathtypes/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 -
trunk/psLib/src/sys/psMemory.c
r876 r1073 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-06- 04 23:46:48$10 * @version $Revision: 1.25 $ $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 … … 30 30 static int checkMemBlock(const psMemBlock *m, const char* funcName); 31 31 static psMemBlock *lastMemBlockAllocated = NULL; 32 pthread_mutex_tmemBlockListMutex = PTHREAD_MUTEX_INITIALIZER;33 pthread_mutex_tmemIdMutex = PTHREAD_MUTEX_INITIALIZER;32 static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; 33 static pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER; 34 34 35 35 /** … … 96 96 psMemoryId p_psMemFreeID = 0; // notify user this block is freed 97 97 98 psMemoryId psMemAllocateCallbackSetID(psMemoryId id) // set p_psMemAllocateID to id98 psMemoryId psMemAllocateCallbackSetID(psMemoryId id) 99 99 { 100 100 psMemoryId old = p_psMemAllocateID; … … 104 104 } 105 105 106 psMemoryId psMemFreeCallbackSetID(psMemoryId id) // set p_psMemFreeID to id106 psMemoryId psMemFreeCallbackSetID(psMemoryId id) 107 107 { 108 108 psMemoryId old = p_psMemFreeID; … … 184 184 #define ALIGNED(P) ((void *)((long)(P) & ~03) == (P)) 185 185 186 static int 187 checkMemBlock(const psMemBlock *m, 188 const char* funcName) 186 static int checkMemBlock(const psMemBlock *m, const char* funcName) 189 187 { 190 188 // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked, … … 260 258 261 259 ptr->file = file; 260 ptr->freeFcn = NULL; 262 261 *(unsigned int*)&ptr->lineno = lineno; 263 262 ptr->startblock = P_PS_MEMMAGIC; … … 346 345 if (checkMemBlock(ptr, __func__) != 0) { 347 346 memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it 348 } 349 350 psMemDecrRefCounter(vptr); // this handles the free, if required. 347 return; 348 } 349 350 (void)psMemDecrRefCounter(vptr); // this handles the free, if required. 351 351 } 352 352 … … 354 354 * Check for memory leaks. Not production quality code 355 355 */ 356 int psMemCheckLeaks( 357 psMemoryId id0, // don't list blocks with id < id0 358 psMemBlock ***arr, // pointer to array of pointers to leaked blocks, or NULL 359 FILE *fd) // print list of leaks to fd (or NULL) 356 int psMemCheckLeaks(psMemoryId id0,psMemBlock ***arr,FILE *fd) 360 357 { 361 358 int nleak = 0; … … 365 362 pthread_mutex_lock(&memBlockListMutex); 366 363 367 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) 368 { 364 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) { 369 365 if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) { 370 366 nleak++; … … 382 378 pthread_mutex_unlock(&memBlockListMutex); 383 379 384 if (nleak == 0 || arr == NULL) 385 { 380 if (nleak == 0 || arr == NULL) { 386 381 return nleak; 387 382 } … … 390 385 pthread_mutex_lock(&memBlockListMutex); 391 386 392 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) 393 { 387 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) { 394 388 if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) { 395 389 (*arr)[j++] = iter; … … 408 402 * Reference counting APIs 409 403 */ 410 psReferenceCount psMemGetRefCounter(void *vptr) // return refCounter 404 // return refCounter 405 psReferenceCount psMemGetRefCounter(void *vptr) 411 406 { 412 407 psMemBlock *ptr; 413 408 unsigned int refCount; 414 409 415 if (vptr == NULL) 416 { 410 if (vptr == NULL) { 417 411 return 0; 418 412 } … … 420 414 ptr = ((psMemBlock *)vptr) - 1; 421 415 422 if (checkMemBlock(ptr, __func__) != 0) 423 { 416 if (checkMemBlock(ptr, __func__) != 0) { 424 417 memProblemCallback(ptr, __func__, __LINE__); 425 418 } … … 431 424 return refCount; 432 425 } 433 434 void *psMemIncrRefCounter(void *vptr) // increment and return refCounter426 // increment and return refCounter 427 void *psMemIncrRefCounter(void *vptr) 435 428 { 436 429 psMemBlock *ptr; 437 430 438 if (vptr == NULL) 439 { 431 if (vptr == NULL) { 440 432 return vptr; 441 433 } … … 443 435 ptr = ((psMemBlock *)vptr) - 1; 444 436 445 if (checkMemBlock(ptr, __func__)) 446 { 437 if (checkMemBlock(ptr, __func__)) { 447 438 memProblemCallback(ptr, __func__, __LINE__); 448 439 } … … 455 446 } 456 447 457 void *psMemDecrRefCounter(void *vptr)// decrement and return refCounter458 { 459 if (vptr == NULL) 460 {448 // decrement and return refCounter 449 void *psMemDecrRefCounter(void *vptr) 450 { 451 if (vptr == NULL) { 461 452 return NULL; 462 453 } … … 467 458 pthread_mutex_lock(&ptr->refCounterMutex); 468 459 469 if (ptr->refCounter > 1) 470 { 460 if (ptr->refCounter > 1) { 471 461 /// XXX - Probably should have another mutex here. 472 462 ptr->refCounter--; // multiple references, just decrement the count. 473 463 pthread_mutex_unlock(&ptr->refCounterMutex); 474 464 475 } else 476 { 465 } else { 477 466 pthread_mutex_unlock(&ptr->refCounterMutex); 478 467 … … 482 471 } 483 472 473 if (ptr->freeFcn != NULL) { 474 ptr->freeFcn(vptr); 475 } 476 484 477 pthread_mutex_lock(&memBlockListMutex); 485 478 … … 507 500 } 508 501 509 void p_psCustomFree(psFreeFcn fcn, void* ptr) 510 { 511 512 if (fcn == NULL) { 502 void p_psMemSetDeallocator(void* vptr, psFreeFcn freeFcn) 503 { 504 if (vptr == NULL) { 513 505 return; 514 } else { 515 if (fcn == PS_FREE) { 516 psFree(ptr); 517 } else { 518 fcn(ptr); 519 } 520 } 521 } 506 } 507 508 psMemBlock *ptr = ((psMemBlock *)vptr) - 1; 509 510 ptr->freeFcn = freeFcn; 511 512 } 513 psFreeFcn p_psMemGetDeallocator(void* vptr) 514 { 515 if (vptr == NULL) { 516 return NULL; 517 } 518 519 psMemBlock *ptr = ((psMemBlock *)vptr) - 1; 520 521 return ptr->freeFcn; 522 } -
trunk/psLib/src/sys/psMemory.h
r978 r1073 14 14 * @ingroup MemoryManagement 15 15 * 16 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-06- 10 02:09:57$16 * @version $Revision: 1.19 $ $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 … … 50 50 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer. 51 51 typedef unsigned long psReferenceCount; 52 53 /// typedef for deallocator. 54 typedef void (*psFreeFcn)(void* ptr); 52 55 53 56 /** Book-keeping data for storage allocator. … … 58 61 typedef struct psMemBlock 59 62 { 60 const void* startblock; ///< initialised to p_psMEMMAGIC 61 struct psMemBlock* previousBlock; ///< previous block in allocation list 62 struct psMemBlock* nextBlock; ///< next block allocation list 63 size_t userMemorySize; ///< the size of the user-portion of the memory block 64 const psMemoryId id; ///< a unique ID for this allocation 65 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 66 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 67 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 68 psReferenceCount refCounter; ///< how many times pointer is referenced 69 const void* endblock; ///< initialised to p_psMEMMAGIC 63 const void* startblock; ///< initialised to p_psMEMMAGIC 64 struct psMemBlock* previousBlock; ///< previous block in allocation list 65 struct psMemBlock* nextBlock; ///< next block allocation list 66 psFreeFcn freeFcn; ///< deallocator. If NULL, use generic deallocation. 67 size_t userMemorySize; ///< the size of the user-portion of the memory block 68 const psMemoryId id; ///< a unique ID for this allocation 69 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 70 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 71 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 72 psReferenceCount refCounter; ///< how many times pointer is referenced 73 const void* endblock; ///< initialised to p_psMEMMAGIC 70 74 } 71 75 psMemBlock; … … 114 118 ); 115 119 116 typedef void (*psFreeFcn)(void* ptr);117 118 120 /** Memory allocation. This operates much like malloc(), but is guaranteed to return a non-NULL value. 119 121 * 120 122 * @return void* pointer to the allocated buffer. This will not be NULL. 121 * @see psFree 123 * @see psFree 122 124 */ 123 125 #ifdef DOXYGEN … … 131 133 int lineno ///< Line number of call 132 134 ); 135 136 void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn); 137 psFreeFcn p_psMemGetDeallocator(void* ptr); 138 133 139 /// Memory allocation. psAlloc sends file and line number to p_psAlloc. 134 140 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__) … … 282 288 ); 283 289 284 #define PS_FREE (void*)1285 286 290 //@} End of Memory Management Functions 287 291 288 289 292 #ifndef DOXYGEN 290 291 void p_psCustomFree(psFreeFcn fcn,void* ptr);292 293 293 294 /* -
trunk/psLib/src/sysUtils/psHash.c
r964 r1073 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06- 10 00:09:55 $12 * @version $Revision: 1.9 $ $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 … … 18 18 #include <stdio.h> 19 19 #include <string.h> 20 #include <stdbool.h> 20 21 #include "psHash.h" 21 22 #include "psMemory.h" … … 24 25 #include "psAbort.h" 25 26 27 static psHashBucket *hashBucketAlloc(const char *key,void *data,psHashBucket *next); 28 static void hashBucketFree(psHashBucket *bucket); 29 static void *doHashWork(psHash* table, const char* key, void* data, bool remove 30 ); 31 static void hashFree(psHash *table); 26 32 27 33 /****************************************************************************** … … 87 93 // Allocate memory for the new hash bucket. 88 94 psHashBucket *bucket = psAlloc(sizeof(psHashBucket)); 95 p_psMemSetDeallocator(bucket,(psFreeFcn)hashBucketFree); 89 96 90 97 // Initialize the bucket. … … 105 112 106 113 /****************************************************************************** 107 hashBucketFree(bucket, itemFree): This procedure deallocates the specified 108 hash bucket. If "itemFree" is NULL, then we simply free the data with the 109 standard psFree() function. If "itemFree" is not NULL, then it must be a 110 function pointer which takes the hash bucket as a parameter, and frees the 111 data in that hash bucket. 114 hashBucketFree(bucket): This procedure deallocates the specified 115 hash bucket. 112 116 Inputs: 113 117 bucket: the hash bucket to be freed. 114 itemFree: a function pointer, possibly NULL.115 118 Return: 116 119 NONE 117 120 *****************************************************************************/ 118 static void hashBucketFree(psHashBucket *bucket, // bucket to free 119 void (*itemFree)(void *item)) // how to free data; 120 { 121 if (bucket == NULL) 122 { 121 static void hashBucketFree(psHashBucket *bucket) 122 { 123 if (bucket == NULL) { 123 124 return; 124 125 } … … 126 127 // A bucket is actually a linked list of buckets. We recursively step 127 128 // through that linked list, free each bucket. 128 if (bucket->next != NULL) 129 { 130 hashBucketFree(bucket, itemFree); 131 } 129 psFree(bucket->next); 132 130 133 131 psFree(bucket->key); 134 psMemDecrRefCounter(bucket->data); 135 136 if (itemFree != NULL) 137 { 138 itemFree(bucket->data); 139 } else 140 { 141 psFree(bucket->data); 142 } 143 144 psFree(bucket); 132 133 psFree(bucket->data); 145 134 } 146 135 … … 159 148 // Create the new hash table. 160 149 psHash *table = psAlloc(sizeof(psHash)); 150 p_psMemSetDeallocator(table,(psFreeFcn)hashFree); 161 151 162 152 // Allocate memory for the buckets. … … 185 175 Inputs: 186 176 table: a hash table 187 itemFree: a function pointer, possibly NULL.188 177 Return: 189 178 NONE 190 179 *****************************************************************************/ 191 void psHashFree(psHash *table, // hash table to be freed 192 void (*itemFree)(void *item)) // how to free hashed data; or NULL 180 static void hashFree(psHash *table) 193 181 { 194 182 psHashBucket *tmp = NULL; // Used to step through linked list. … … 196 184 int i = 0; // Loop index variable. 197 185 198 if (table == NULL) 199 { 186 if (table == NULL) { 200 187 return; 201 188 } … … 204 191 // NULL, then free the bucket via a function call to hashBucketFree(); 205 192 206 for (i = 0; i < table->nbucket; i++) 207 { 193 for (i = 0; i < table->nbucket; i++) { 208 194 // A bucket is composed of a linked list of buckets. We use the 209 195 // "tmp" and "ptr" pointers to step through that list and free each … … 214 200 while (ptr != NULL) { 215 201 tmp = ptr->next; 216 hashBucketFree(ptr, itemFree);202 psFree(ptr); 217 203 ptr = tmp; 218 204 } … … 222 208 // Free the bucket structure, then the hash table. 223 209 psFree(table->buckets); 224 psFree(table); 225 } 226 227 /****************************************************************************** 228 doHashWork(table, key, data, remove, itemFree): This is an internal 210 } 211 212 /****************************************************************************** 213 doHashWork(table, key, data, remove): This is an internal 229 214 procedure which does the bulk of the work in using the hash table. Depending 230 215 upon the input parameters, it will either insert a new key/data into the hash 231 216 table, retrieve the data for a specified key, or remove a key/data item. If 232 we try to insert a key that already exists in the hash table, then we call 233 the user-supplied function itemfree (or psFree if that is NULL), to free the 234 existing data/key item. 217 we try to insert a key that already exists in the hash table, then we deallocate 218 the existing data/key item. 235 219 Inputs: 236 220 table: a hash table … … 238 222 data: the data to insert, if not NULL 239 223 remove: set to non-zero if the key/data should be removed from the table. 240 itemFree: function pointer241 224 Return: 242 225 NONE … … 246 229 there is little common code between those functions. 247 230 *****************************************************************************/ 248 static void *doHashWork(psHash *table, // table to insert in 249 const char *key, // key to use 250 void *data, // data to insert, or (if NULL) retrieve/remove 251 int remove 252 , // remove the item from the list? 253 void (*itemFree)(void *item)) // how to free hashed data 231 static void *doHashWork(psHash *table, const char *key, void *data, bool remove 232 ) 254 233 { 255 234 long int hash = 1; // This will contain an integer value … … 313 292 } 314 293 315 psFree(ptr->key);316 294 psFree(ptr); 317 295 318 296 // By definition, the data associated with that key 319 297 // must be returned, not freed. 320 return psMemDecrRefCounter(data);298 return data; 321 299 } 322 300 optr = ptr; … … 354 332 // the new data was not inserted into the hash table. 355 333 356 if (itemFree == NULL) { 357 psFree(psMemDecrRefCounter(ptr->data)); 358 } else { 359 itemFree(psMemDecrRefCounter(ptr->data)); 360 } 334 psFree(ptr->data); 361 335 362 336 ptr->data = psMemIncrRefCounter(data); … … 385 359 NONE 386 360 *****************************************************************************/ 387 void *psHashInsert(psHash *table, // table to insert in 388 const char *key, // key to use 389 void *data, // data to insert 390 void (*itemFree)(void *item)) // how to free hashed data; 361 void *psHashInsert(psHash *table, const char *key, void *data) 391 362 { 392 363 if (table == NULL) { … … 400 371 } 401 372 402 return doHashWork(table, key, data, 0 , itemFree);373 return doHashWork(table, key, data, 0); 403 374 } 404 375 … … 425 396 426 397 427 return doHashWork(table, key, NULL, 0 , NULL);398 return doHashWork(table, key, NULL, 0); 428 399 } 429 400 … … 438 409 The data that was associated with that key. 439 410 *****************************************************************************/ 440 void *psHashRemove(psHash *table, // table to lookup key in 441 const char *key, // key to lookup 442 void (*itemFree)(void *item)) // how to free hashed data; 411 void *psHashRemove(psHash *table, const char *key) 443 412 { 444 413 if (table == NULL) { … … 449 418 } 450 419 451 return doHashWork(table, key, NULL, 1 , itemFree);452 } 420 return doHashWork(table, key, NULL, 1); 421 } -
trunk/psLib/src/sysUtils/psHash.d
r1041 r1073 1 1 psHash.o psHash.d : psHash.c psHash.h ../collections/psList.h \ 2 ../collections/psVector.h ../collections/psType.h \3 ../sysUtils/psMemory.h psString.hpsTrace.h psAbort.h2 ../collections/psVector.h ../collections/psType.h psMemory.h psString.h \ 3 psTrace.h psAbort.h -
trunk/psLib/src/sysUtils/psHash.h
r1013 r1073 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06- 12 05:50:01$12 * @version $Revision: 1.14 $ $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 … … 45 45 ); 46 46 47 /// Free hash buckets from table.48 void psHashFree(psHash *table, ///< hash table to be freed49 void (*itemFree)(void *item) ///< how to free hashed data; or NULL50 );51 52 47 /// Insert entry into table. 53 48 void *psHashInsert(psHash *table, ///< table to insert in 54 49 const char *key, ///< key to use 55 void *data, ///< data to insert 56 void (*itemFree)(void *item) ///< how to free hashed data; or NULL 50 void *data ///< data to insert 57 51 ); 58 52 59 53 /// Lookup key in table. 60 void *psHashLookup(psHash *table, ///< table to lookup key in61 const char *key ///< key to lookup54 void *psHashLookup(psHash *table, ///< table to lookup key in 55 const char *key ///< key to lookup 62 56 ); 63 57 64 58 /// Remove key from table. 65 void *psHashRemove(psHash *table, ///< table to lookup key in 66 const char *key, ///< key to lookup 67 void (*itemFree)(void *item) ///< how to free hashed data; or NULL 59 void *psHashRemove(psHash *table, ///< table to lookup key in 60 const char *key ///< key to lookup 68 61 ); 69 62 -
trunk/psLib/src/sysUtils/psMemory.c
r876 r1073 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-06- 04 23:46:48$10 * @version $Revision: 1.25 $ $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 … … 30 30 static int checkMemBlock(const psMemBlock *m, const char* funcName); 31 31 static psMemBlock *lastMemBlockAllocated = NULL; 32 pthread_mutex_tmemBlockListMutex = PTHREAD_MUTEX_INITIALIZER;33 pthread_mutex_tmemIdMutex = PTHREAD_MUTEX_INITIALIZER;32 static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; 33 static pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER; 34 34 35 35 /** … … 96 96 psMemoryId p_psMemFreeID = 0; // notify user this block is freed 97 97 98 psMemoryId psMemAllocateCallbackSetID(psMemoryId id) // set p_psMemAllocateID to id98 psMemoryId psMemAllocateCallbackSetID(psMemoryId id) 99 99 { 100 100 psMemoryId old = p_psMemAllocateID; … … 104 104 } 105 105 106 psMemoryId psMemFreeCallbackSetID(psMemoryId id) // set p_psMemFreeID to id106 psMemoryId psMemFreeCallbackSetID(psMemoryId id) 107 107 { 108 108 psMemoryId old = p_psMemFreeID; … … 184 184 #define ALIGNED(P) ((void *)((long)(P) & ~03) == (P)) 185 185 186 static int 187 checkMemBlock(const psMemBlock *m, 188 const char* funcName) 186 static int checkMemBlock(const psMemBlock *m, const char* funcName) 189 187 { 190 188 // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked, … … 260 258 261 259 ptr->file = file; 260 ptr->freeFcn = NULL; 262 261 *(unsigned int*)&ptr->lineno = lineno; 263 262 ptr->startblock = P_PS_MEMMAGIC; … … 346 345 if (checkMemBlock(ptr, __func__) != 0) { 347 346 memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it 348 } 349 350 psMemDecrRefCounter(vptr); // this handles the free, if required. 347 return; 348 } 349 350 (void)psMemDecrRefCounter(vptr); // this handles the free, if required. 351 351 } 352 352 … … 354 354 * Check for memory leaks. Not production quality code 355 355 */ 356 int psMemCheckLeaks( 357 psMemoryId id0, // don't list blocks with id < id0 358 psMemBlock ***arr, // pointer to array of pointers to leaked blocks, or NULL 359 FILE *fd) // print list of leaks to fd (or NULL) 356 int psMemCheckLeaks(psMemoryId id0,psMemBlock ***arr,FILE *fd) 360 357 { 361 358 int nleak = 0; … … 365 362 pthread_mutex_lock(&memBlockListMutex); 366 363 367 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) 368 { 364 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) { 369 365 if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) { 370 366 nleak++; … … 382 378 pthread_mutex_unlock(&memBlockListMutex); 383 379 384 if (nleak == 0 || arr == NULL) 385 { 380 if (nleak == 0 || arr == NULL) { 386 381 return nleak; 387 382 } … … 390 385 pthread_mutex_lock(&memBlockListMutex); 391 386 392 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) 393 { 387 for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) { 394 388 if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) { 395 389 (*arr)[j++] = iter; … … 408 402 * Reference counting APIs 409 403 */ 410 psReferenceCount psMemGetRefCounter(void *vptr) // return refCounter 404 // return refCounter 405 psReferenceCount psMemGetRefCounter(void *vptr) 411 406 { 412 407 psMemBlock *ptr; 413 408 unsigned int refCount; 414 409 415 if (vptr == NULL) 416 { 410 if (vptr == NULL) { 417 411 return 0; 418 412 } … … 420 414 ptr = ((psMemBlock *)vptr) - 1; 421 415 422 if (checkMemBlock(ptr, __func__) != 0) 423 { 416 if (checkMemBlock(ptr, __func__) != 0) { 424 417 memProblemCallback(ptr, __func__, __LINE__); 425 418 } … … 431 424 return refCount; 432 425 } 433 434 void *psMemIncrRefCounter(void *vptr) // increment and return refCounter426 // increment and return refCounter 427 void *psMemIncrRefCounter(void *vptr) 435 428 { 436 429 psMemBlock *ptr; 437 430 438 if (vptr == NULL) 439 { 431 if (vptr == NULL) { 440 432 return vptr; 441 433 } … … 443 435 ptr = ((psMemBlock *)vptr) - 1; 444 436 445 if (checkMemBlock(ptr, __func__)) 446 { 437 if (checkMemBlock(ptr, __func__)) { 447 438 memProblemCallback(ptr, __func__, __LINE__); 448 439 } … … 455 446 } 456 447 457 void *psMemDecrRefCounter(void *vptr)// decrement and return refCounter458 { 459 if (vptr == NULL) 460 {448 // decrement and return refCounter 449 void *psMemDecrRefCounter(void *vptr) 450 { 451 if (vptr == NULL) { 461 452 return NULL; 462 453 } … … 467 458 pthread_mutex_lock(&ptr->refCounterMutex); 468 459 469 if (ptr->refCounter > 1) 470 { 460 if (ptr->refCounter > 1) { 471 461 /// XXX - Probably should have another mutex here. 472 462 ptr->refCounter--; // multiple references, just decrement the count. 473 463 pthread_mutex_unlock(&ptr->refCounterMutex); 474 464 475 } else 476 { 465 } else { 477 466 pthread_mutex_unlock(&ptr->refCounterMutex); 478 467 … … 482 471 } 483 472 473 if (ptr->freeFcn != NULL) { 474 ptr->freeFcn(vptr); 475 } 476 484 477 pthread_mutex_lock(&memBlockListMutex); 485 478 … … 507 500 } 508 501 509 void p_psCustomFree(psFreeFcn fcn, void* ptr) 510 { 511 512 if (fcn == NULL) { 502 void p_psMemSetDeallocator(void* vptr, psFreeFcn freeFcn) 503 { 504 if (vptr == NULL) { 513 505 return; 514 } else { 515 if (fcn == PS_FREE) { 516 psFree(ptr); 517 } else { 518 fcn(ptr); 519 } 520 } 521 } 506 } 507 508 psMemBlock *ptr = ((psMemBlock *)vptr) - 1; 509 510 ptr->freeFcn = freeFcn; 511 512 } 513 psFreeFcn p_psMemGetDeallocator(void* vptr) 514 { 515 if (vptr == NULL) { 516 return NULL; 517 } 518 519 psMemBlock *ptr = ((psMemBlock *)vptr) - 1; 520 521 return ptr->freeFcn; 522 } -
trunk/psLib/src/sysUtils/psMemory.h
r978 r1073 14 14 * @ingroup MemoryManagement 15 15 * 16 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-06- 10 02:09:57$16 * @version $Revision: 1.19 $ $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 … … 50 50 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer. 51 51 typedef unsigned long psReferenceCount; 52 53 /// typedef for deallocator. 54 typedef void (*psFreeFcn)(void* ptr); 52 55 53 56 /** Book-keeping data for storage allocator. … … 58 61 typedef struct psMemBlock 59 62 { 60 const void* startblock; ///< initialised to p_psMEMMAGIC 61 struct psMemBlock* previousBlock; ///< previous block in allocation list 62 struct psMemBlock* nextBlock; ///< next block allocation list 63 size_t userMemorySize; ///< the size of the user-portion of the memory block 64 const psMemoryId id; ///< a unique ID for this allocation 65 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 66 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 67 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 68 psReferenceCount refCounter; ///< how many times pointer is referenced 69 const void* endblock; ///< initialised to p_psMEMMAGIC 63 const void* startblock; ///< initialised to p_psMEMMAGIC 64 struct psMemBlock* previousBlock; ///< previous block in allocation list 65 struct psMemBlock* nextBlock; ///< next block allocation list 66 psFreeFcn freeFcn; ///< deallocator. If NULL, use generic deallocation. 67 size_t userMemorySize; ///< the size of the user-portion of the memory block 68 const psMemoryId id; ///< a unique ID for this allocation 69 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 70 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 71 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 72 psReferenceCount refCounter; ///< how many times pointer is referenced 73 const void* endblock; ///< initialised to p_psMEMMAGIC 70 74 } 71 75 psMemBlock; … … 114 118 ); 115 119 116 typedef void (*psFreeFcn)(void* ptr);117 118 120 /** Memory allocation. This operates much like malloc(), but is guaranteed to return a non-NULL value. 119 121 * 120 122 * @return void* pointer to the allocated buffer. This will not be NULL. 121 * @see psFree 123 * @see psFree 122 124 */ 123 125 #ifdef DOXYGEN … … 131 133 int lineno ///< Line number of call 132 134 ); 135 136 void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn); 137 psFreeFcn p_psMemGetDeallocator(void* ptr); 138 133 139 /// Memory allocation. psAlloc sends file and line number to p_psAlloc. 134 140 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__) … … 282 288 ); 283 289 284 #define PS_FREE (void*)1285 286 290 //@} End of Memory Management Functions 287 291 288 289 292 #ifndef DOXYGEN 290 291 void p_psCustomFree(psFreeFcn fcn,void* ptr);292 293 293 294 /* -
trunk/psLib/src/types/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/types/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/types/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/types/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.
Note:
See TracChangeset
for help on using the changeset viewer.
