Changeset 4212 for trunk/psLib/src/collections
- Timestamp:
- Jun 10, 2005, 11:46:46 AM (21 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 5 edited
-
psCollectionsErrors.dat (modified) (1 diff)
-
psCollectionsErrors.h (modified) (2 diffs)
-
psPixels.c (modified) (4 diffs)
-
psVector.c (modified) (3 diffs)
-
psVector.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psCollectionsErrors.dat
r3959 r4212 16 16 psVector_SORT_NULL psVectorSort can not sort a NULL psVector. 17 17 psVector_UNSUPPORTED_TYPE Input psVector is an unsupported type (0x%x). 18 psVector_NULL The input psVector can not be NULL. 19 psVector_EXTENDSIZE_NEG The input number of elements to extend must be non-negative. 18 20 # 19 21 psBitSet_ALLOC_NEG_SIZE The number of bit in a psBitSet (%d) must be greater than zero. -
trunk/psLib/src/collections/psCollectionsErrors.h
r4162 r4212 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-06- 08 23:40:45$9 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-06-10 21:46:46 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 37 37 #define PS_ERRORTEXT_psVector_SORT_NULL "psVectorSort can not sort a NULL psVector." 38 38 #define PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE "Input psVector is an unsupported type (0x%x)." 39 #define PS_ERRORTEXT_psVector_NULL "The input psVector can not be NULL." 40 #define PS_ERRORTEXT_psVector_EXTENDSIZE_NEG "The input number of elements to extend must be non-negative." 39 41 #define PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE "The number of bit in a psBitSet (%d) must be greater than zero." 40 42 #define PS_ERRORTEXT_psBitSet_SET_NULL "Can not operate on a NULL psBitSet." -
trunk/psLib/src/collections/psPixels.c
r4203 r4212 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-06- 09 23:51:49$9 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-06-10 21:46:46 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 132 132 133 133 // determine the output image size 134 int numRows = x1-x0;135 int numCols = y1-y0;134 int numRows = y1-y0; 135 int numCols = x1-x0; 136 136 if (numRows < 1 || numCols < 1) { 137 137 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 138 138 PS_ERRORTEXT_psPixels_REGION_INVALID, 139 x0,x1,y0,y1);139 y0,y1,x0,x1); 140 140 psFree(out); 141 141 return NULL; … … 150 150 return NULL; 151 151 } 152 *(psS32*)&out->row0 = x0;153 *(psS32*)&out->col0 = y0;152 *(psS32*)&out->row0 = y0; 153 *(psS32*)&out->col0 = x0; 154 154 155 155 // initialize image to all zeros … … 169 169 // pixel in region? 170 170 if (x >= x0 && x < x1 && y >= y0 && y < y1) { 171 outData[ x-x0][y-y0] |= maskVal;171 outData[y-y0][x-x0] |= maskVal; 172 172 } 173 173 } -
trunk/psLib/src/collections/psVector.c
r3786 r4212 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 4-29 02:25:09$11 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-06-10 21:46:46 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 54 54 55 55 elementSize = PSELEMTYPE_SIZEOF(elemType); 56 if (elementSize < 1) { 57 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 58 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, elemType); 59 return NULL; 60 } 61 56 62 57 63 // Create vector struct … … 121 127 in->n = n; 122 128 return in; 129 } 130 131 psVector *psVectorExtend(psVector *vector, int delta, int nExtend) 132 { 133 // can't handle a NULL vector (don't know the data type to allocate) 134 if (vector == NULL) { 135 psError(PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psVector_NULL); 137 return NULL; 138 } 139 140 // requirement on delta; if < 1, set to 10. 141 if (delta < 1) { 142 delta = 10; 143 } 144 145 // adjust the allocated size, if needed. (if nExtend < 1, this is will never happen) 146 if (nExtend > 0) { 147 unsigned int minAlloc = vector->n + nExtend + nExtend; 148 if (vector->nalloc < minAlloc) { 149 unsigned int nAlloc = delta + vector->nalloc; 150 // make sure the delta is large enough hold twice the extended length. 151 if (nAlloc < minAlloc) { 152 nAlloc = minAlloc; 153 } 154 vector = psVectorRealloc(vector, nAlloc); 155 } 156 } else if (nExtend < -vector->n) { 157 // For the case of a negative nExtend, need to check that we are not decreasing 158 // vector beyond its own length (i.e., creating a negative length). 159 nExtend = -vector->n; 160 } 161 162 // increment the length by the value specified 163 vector->n += nExtend; 164 165 return vector; 123 166 } 124 167 -
trunk/psLib/src/collections/psVector.h
r4162 r4212 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-06- 08 23:40:45$13 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-10 21:46:46 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 88 88 psVector* psVec, ///< Vector to reallocate. 89 89 psU32 nalloc ///< Total number of elements to make available. 90 ); 91 92 /** Extend a vector's length. 93 * 94 * Increments a vector's length, n, by the specified number of elements. 95 * If the allocated storage is less than the current vector's length plus 96 * twice the number of elements to be added, it is reallocated larger by 97 * a given amount. 98 * 99 * @return psVector* Pointer to the adjusted psVector 100 */ 101 psVector *psVectorExtend( 102 psVector *vector, ///< Vector to extend 103 int delta, ///< Amount to expand allocation, if necessary 104 int nExtend ///< Number of elements to add to vector length 90 105 ); 91 106
Note:
See TracChangeset
for help on using the changeset viewer.
