Changeset 4212 for trunk/psLib/src/collections/psVector.c
- Timestamp:
- Jun 10, 2005, 11:46:46 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psVector.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
