Changeset 6551
- Timestamp:
- Mar 8, 2006, 4:42:56 PM (20 years ago)
- File:
-
- 1 edited
-
branches/rel10_ifa/psLib/src/types/psArray.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psLib/src/types/psArray.c
r5530 r6551 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $12 * @date $Date: 200 5-11-16 23:06:35$11 * @version $Revision: 1.40.10.1 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-03-09 02:42:56 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 // Create vector data array 69 69 psArr->data = psAlloc(nalloc * sizeof(psPtr)); 70 // Set everything to NULL 71 memset(psArr->data, (int)NULL, nalloc*sizeof(psPtr)); 70 72 71 73 return psArr; … … 78 80 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psArray_REALLOC_NULL); 79 81 return NULL; 80 } else if (in->nalloc != nalloc) { // No need to realloc to same size 82 } 83 if (in->nalloc != nalloc) { // No need to realloc to same size 81 84 if (nalloc < in->n) { 82 85 for (psS32 i = nalloc; i < in->n; i++) { // For reduction in vector size … … 87 90 // Realloc after decrementation to avoid accessing freed array elements 88 91 in->data = psRealloc(in->data, nalloc * sizeof(psPtr)); 92 if (nalloc > in->nalloc) { 93 // Expanding the array: set new pointers to NULL 94 memset(&in->data[in->nalloc], (int)NULL, nalloc - in->nalloc); 95 } 89 96 P_PSARRAY_SET_NALLOC(in,nalloc); 90 97 }
Note:
See TracChangeset
for help on using the changeset viewer.
