IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2004, 1:29:39 PM (22 years ago)
Author:
harman
Message:

Changed psVector to be consistent with psImage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psVector.c

    r811 r831  
    1919 *  @author Ross Harman, MHPCC
    2020 *   
    21  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    22  *  @date $Date: 2004-05-29 01:08:46 $
     21 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     22 *  @date $Date: 2004-06-02 23:29:14 $
    2323 *
    2424 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6464/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    6565/*****************************************************************************/
    66 psVector* psVectorAlloc(psElemType elemType, unsigned int nalloc)
     66psVector* psVectorAlloc(unsigned int nalloc, psElemType elemType)
    6767{
    6868    psVector *psVec = NULL;
     
    8686
    8787    // Create vector data array
    88     psVec->vec.v = psAlloc(nalloc*elementSize);
     88    psVec->data.V = psAlloc(nalloc*elementSize);
    8989
    9090    return psVec;
    9191}
    9292
    93 psVector *psVectorRealloc(psVector *restrict in, unsigned int nalloc)
     93psVector *psVectorRealloc(unsigned int nalloc, psVector *restrict in)
    9494{
    9595    int elementSize = 0;
     
    110110            if (elemType == PS_TYPE_PTR) {
    111111                for (int i = nalloc; i < in->n; i++) {   // For reduction in vector size
    112                     psMemDecrRefCounter(in->vec.vp[i]);
     112                    psMemDecrRefCounter(in->data.PTR[i]);
    113113                }
    114114            }
     
    117117
    118118        // Realloc after decrementation to avoid accessing freed array elements
    119         in->vec.v = psRealloc(in->vec.v,nalloc*elementSize);
     119        in->data.V = psRealloc(in->data.V,nalloc*elementSize);
    120120        in->nalloc = nalloc;
    121121    }
     
    129129
    130130    if (in == NULL) {
    131         return psVectorAlloc(type,nalloc);
     131        return psVectorAlloc(nalloc, type);
    132132    }
    133133
     
    150150    if (elemType == PS_TYPE_PTR) {
    151151        for (int i = 0; i < in->n; i++) {   // For reduction in vector size
    152             psMemDecrRefCounter(in->vec.vp[i]);
    153             in->vec.vp[i] = NULL;
     152            psMemDecrRefCounter(in->data.PTR[i]);
     153            in->data.PTR[i] = NULL;
    154154        }
    155155    }
    156156
    157     in->vec.v = psRealloc(in->vec.v,nalloc*PSELEMTYPE_SIZEOF(elemType));
     157    in->data.V = psRealloc(in->data.V,nalloc*PSELEMTYPE_SIZEOF(elemType));
    158158
    159159    in->n = 0;
     
    170170    }
    171171
    172     psFree(psVec->vec.v);
     172    psFree(psVec->data.V);
    173173    psFree(psVec);
    174174}
     
    188188    for(int i = 0; i < psVec->nalloc; i++) {
    189189        if(elemFree == NULL) {
    190             psMemDecrRefCounter(psVec->vec.vp[i]);
     190            psMemDecrRefCounter(psVec->data.PTR[i]);
    191191        } else {
    192             elemFree(psMemDecrRefCounter(psVec->vec.vp[i]));
     192            elemFree(psMemDecrRefCounter(psVec->data.PTR[i]));
    193193        }
    194         psVec->vec.vp[i] = NULL;
     194        psVec->data.PTR[i] = NULL;
    195195    }
    196196}
Note: See TracChangeset for help on using the changeset viewer.