Changeset 9730 for trunk/psLib/src/mathtypes
- Timestamp:
- Oct 24, 2006, 12:55:05 PM (20 years ago)
- Location:
- trunk/psLib/src/mathtypes
- Files:
-
- 2 edited
-
psVector.c (modified) (3 diffs)
-
psVector.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psVector.c
r9554 r9730 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.8 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-10- 14 00:12:39$11 * @version $Revision: 1.87 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-10-24 22:52:56 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 69 69 70 psVector* psVectorAlloc(long nalloc, 71 psElemType type) 72 { 73 psVector* psVec = NULL; 74 psS32 elementSize = 0; 75 76 elementSize = PSELEMTYPE_SIZEOF(type); 70 // Allocate a psVector; does not set vector->n (left to the caller) 71 static psVector *vectorAlloc(long nalloc, // Number of elements to allocate 72 psElemType type // Type of elements 73 ) 74 { 75 int elementSize = PSELEMTYPE_SIZEOF(type); // Size, in bytes, of element 77 76 if (elementSize < 1) { 78 77 psError(PS_ERR_BAD_PARAMETER_TYPE, true, … … 81 80 } 82 81 83 84 82 // Create vector struct 85 psVec = (psVector* ) psAlloc(sizeof(psVector)); 86 psMemSetDeallocator(psVec, (psFreeFunc) vectorFree); 87 88 psVec->type.dimen = PS_DIMEN_VECTOR; 89 psVec->type.type = type; 90 P_PSVECTOR_SET_NALLOC(psVec,nalloc); 91 // psVec->n = nalloc; 92 psVec->n = 0; 83 psVector *vector = (psVector*) psAlloc(sizeof(psVector)); 84 psMemSetDeallocator(vector, (psFreeFunc) vectorFree); 85 86 vector->type.dimen = PS_DIMEN_VECTOR; 87 vector->type.type = type; 88 P_PSVECTOR_SET_NALLOC(vector, nalloc); 93 89 94 90 // Create vector data array 95 psVec->data.U8 = psAlloc(nalloc * elementSize); 96 97 return psVec; 91 vector->data.U8 = psAlloc(nalloc * elementSize); 92 93 return vector; 94 } 95 96 psVector* psVectorAlloc(long nalloc, 97 psElemType type) 98 { 99 psVector *vector = vectorAlloc(nalloc, type); 100 if (!vector) { 101 return NULL; 102 } 103 vector->n = nalloc; 104 return vector; 105 } 106 107 psVector* psVectorAllocEmpty(long nalloc, 108 psElemType type) 109 { 110 psVector *vector = vectorAlloc(nalloc, type); 111 if (!vector) { 112 return NULL; 113 } 114 vector->n = 0; 115 return vector; 98 116 } 99 117 -
trunk/psLib/src/mathtypes/psVector.h
r9553 r9730 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-10- 14 00:07:13$13 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-10-24 22:52:56 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 74 74 ; 75 75 76 /** Allocate a vector .76 /** Allocate a vector, with length set to number allocated 77 77 * 78 78 * Uses psLib memory allocation functions to create a vector collection of … … 82 82 */ 83 83 psVector* psVectorAlloc( 84 long nalloc, ///< Total number of elements to make available. 85 psElemType type ///< Type of data to be held by vector. 86 ); 87 88 /** Allocate a vector, with length set to zero 89 * 90 * Uses psLib memory allocation functions to create a vector collection of 91 * data as defined by the psType type. 92 * 93 * @return psVector* Pointer to psVector. 94 */ 95 psVector* psVectorAllocEmpty( 84 96 long nalloc, ///< Total number of elements to make available. 85 97 psElemType type ///< Type of data to be held by vector.
Note:
See TracChangeset
for help on using the changeset viewer.
