Changeset 15454
- Timestamp:
- Nov 5, 2007, 1:42:46 PM (19 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 3 edited
-
mathtypes/psImage.c (modified) (3 diffs)
-
types/psArray.c (modified) (6 diffs)
-
types/psArray.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psImage.c
r14921 r15454 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.13 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2007- 09-20 23:48:30$11 * @version $Revision: 1.131 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-11-05 23:42:46 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 44 44 // if I am a child, remove me from my parent's array of children 45 45 if (parent != NULL) { 46 // sanity check : a child cannot also be a parent47 if ((image->children != NULL) && (image->children->n > 0)) {48 psAbort ("psImage cannot be both child and parent!");49 }50 51 // break the back-pointer first so we don't loop52 image->parent = NULL; 53 54 // drop my entry on my parent's array of children55 psArrayRemoveDataNoFree (parent->children, image); 56 57 // drop my reference to my parent58 psFree (parent);59 } 60 46 // sanity check : a child cannot also be a parent 47 if ((image->children != NULL) && (image->children->n > 0)) { 48 psAbort ("psImage cannot be both child and parent!"); 49 } 50 51 // break the back-pointer first so we don't loop 52 image->parent = NULL; 53 54 // drop my entry on my parent's array of children 55 psArrayRemoveDataNoFree (parent->children, image); 56 57 // drop my reference to my parent 58 psFree (parent); 59 } 60 61 61 // sanity check: this function should never be reached if an image still has live children; 62 62 // they should each be holding a pointer to the image, forcing the number of references to 63 63 // be > 1. 64 64 if (image->children && (image->children->n > 0)) { 65 psAbort ("psImage memory management programming error : imageFree called on image with live children");65 psAbort ("psImage memory management programming error : imageFree called on image with live children"); 66 66 } 67 67 … … 100 100 psMemSetDeallocator(image, (psFreeFunc) imageFree); 101 101 102 image->data.V = p sAlloc(sizeof(psPtr ) * numRows);103 104 image->p_rawDataBuffer = p sAlloc(numBytes);102 image->data.V = p_psAlloc(file, lineno, func, sizeof(psPtr ) * numRows); 103 104 image->p_rawDataBuffer = p_psAlloc(file, lineno, func, numBytes); 105 105 106 106 // set the row pointers. -
trunk/psLib/src/types/psArray.c
r15115 r15454 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.6 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2007- 09-29 22:18:09$11 * @version $Revision: 1.65 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-11-05 23:42:46 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 139 139 } 140 140 141 psArray* psArrayAdd(psArray* array, 142 long delta, 143 psPtr data) 141 psArray* p_psArrayAdd(const char *file, unsigned int lineno, const char *func, 142 psArray* array, long delta, psPtr data) 144 143 { 145 144 if (array == NULL) { 146 145 long d = (delta > 0) ? delta : DEFAULT_ARRAY_ADD; 147 array = p sArrayAlloc(d);146 array = p_psArrayAlloc(file, lineno, func, d); 148 147 array->n = 0; 149 148 } … … 154 153 // array needs to be expanded to make room for more elements 155 154 long d = (delta > 0) ? delta : DEFAULT_ARRAY_ADD; 156 array = p sArrayRealloc(array, n+d);155 array = p_psArrayRealloc(file, lineno, func, array, n+d); 157 156 } 158 157 … … 187 186 } 188 187 189 // drop an item from the array and do not free it: this 188 // drop an item from the array and do not free it: this 190 189 // can be useful in the free function of a data type 191 190 // with a reference on another structure 192 191 bool psArrayRemoveDataNoFree(psArray* array, 193 const psPtr data)192 const psPtr data) 194 193 { 195 194 PS_ASSERT_ARRAY_NON_NULL(array, false); … … 268 267 while (1) { 269 268 if (I > 0) { 270 // I--;269 // I--; 271 270 temp = index[--I]; 272 271 } else { 273 272 temp = index[J]; 274 273 index[J] = index[0]; 275 // J--;274 // J--; 276 275 if (--J == 0) { 277 276 index[0] = temp; … … 282 281 long j = (I << 1) + 1; 283 282 while (j <= J) { 284 if (j < J) {285 result = func (in->data[index[j]], in->data[index[j+1]]);286 if (result < 0) {287 j++;288 }289 }290 result = func (in->data[temp], in->data[index[j]]);283 if (j < J) { 284 result = func (in->data[index[j]], in->data[index[j+1]]); 285 if (result < 0) { 286 j++; 287 } 288 } 289 result = func (in->data[temp], in->data[index[j]]); 291 290 if (result < 0) { 292 291 index[i]=index[j]; -
trunk/psLib/src/types/psArray.h
r15076 r15454 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.5 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2007- 09-28 21:03:24$12 * @version $Revision: 1.52 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-11-05 23:42:46 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 139 139 * necessary. 140 140 * 141 * If delta < 1, then 10 is used. 142 * 141 143 * @return psArray* The array with the element added 142 144 */ 143 145 psArray* psArrayAdd( 144 146 psArray* array, ///< array to operate on 145 long delta, ///< the amount to expand array, if necessary. If less than one, 10 will be used.147 long delta, ///< the amount to expand array, if necessary. 146 148 psPtr data ///< the data pointer to add to psArray 147 149 ); 150 #ifdef DOXYGEN 151 psArray* psArrayAdd( 152 psArray* array, ///< array to operate on 153 long delta, ///< the amount to expand array, if necessary. 154 psPtr data ///< the data pointer to add to psArray 155 ); 156 #else // ifdef DOXYGEN 157 psArray* p_psArrayAdd( 158 const char *file, ///< File of caller 159 unsigned int lineno, ///< Line number of caller 160 const char *func, ///< Function name of caller 161 psArray* array, ///< array to operate on 162 long delta, ///< the amount to expand array, if necessary. 163 psPtr data ///< the data pointer to add to psArray 164 ) PS_ATTR_MALLOC; 165 #define psArrayAdd(array, delta, data) \ 166 p_psArrayAdd(__FILE__, __LINE__, __func__, array, delta, data) 167 #endif // ifdef DOXYGEN 148 168 149 169
Note:
See TracChangeset
for help on using the changeset viewer.
