IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2005, 3:04:01 PM (21 years ago)
Author:
desonia
Message:

added some helpful functionality to help SWIG.

File:
1 edited

Legend:

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

    r3115 r3165  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-03 00:54:10 $
     11 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-02-09 01:04:01 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    157157    return in;
    158158}
     159
     160/// Set an element in the array.
     161psBool psArraySet(psArray* in,                       ///< input array to set element in
     162                  psU32 position,                    ///< the element position to set
     163                  void* value)                       ///< the value to set it to
     164{
     165    if (in == NULL)
     166    {
     167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     168                PS_ERRORTEXT_psArray_ARRAY_NULL);
     169        return false;
     170    }
     171
     172    if (position >= in->nalloc)
     173    {
     174        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     175                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     176                position, in->nalloc);
     177        return false;
     178    }
     179
     180    psFree(in->data[position]);
     181    in->data[position] = value;
     182
     183    return true;
     184}
     185
     186/// Get an element in the array.
     187void* psArrayGet(psArray* in, psU32 position )
     188{
     189    if (in == NULL) {
     190        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     191                PS_ERRORTEXT_psArray_ARRAY_NULL);
     192        return NULL;
     193    }
     194
     195    if (position >= in->nalloc) {
     196        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     197                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     198                position, in->nalloc);
     199        return NULL;
     200    }
     201
     202    return in->data[position];
     203}
     204
     205
     206
     207
Note: See TracChangeset for help on using the changeset viewer.