IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5114 for trunk/psLib/src/types


Ignore:
Timestamp:
Sep 23, 2005, 2:17:44 PM (21 years ago)
Author:
drobbin
Message:

Updated, fixed, and added error tests to the Set/Get functions & tests

Location:
trunk/psLib/src/types
Files:
4 edited

Legend:

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

    r4898 r5114  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-08-30 01:14:13 $
     11 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-24 00:17:44 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    178178    }
    179179
    180     if (position >= array->nalloc)
    181     {
    182         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    183                 PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
    184                 position, array->nalloc);
    185         return false;
    186     }
    187 
     180    if (position > array->n)
     181    {
     182        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     183                "Specified position, %ld, is greater than n+1 of the array, %ld.",
     184                position, array->n);
     185        return false;
     186    }
     187
     188    if (position < 0)
     189        position += array->n;
     190    if (position < 0)
     191    {
     192        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     193        return false;
     194    }
     195
     196    if (position == array->n)
     197    {
     198        if (position >= array->nalloc) {
     199            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     200                    PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     201                    position, array->nalloc);
     202            return false;
     203        }
     204        array->n++;
     205    }
    188206    psFree(array->data[position]);
    189207    array->data[position] = data;
     
    202220    }
    203221
    204     if (position >= array->nalloc) {
    205         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    206                 PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
    207                 position, array->nalloc);
    208         return NULL;
    209     }
    210 
     222    if (position >= array->n) {
     223        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     224                "Specified position, %ld, is greater than n+1 of the array, %ld.",
     225                position, array->n);
     226        return NULL;
     227    }
     228    if (position < 0)
     229        position += array->n;
     230    if (position < 0) {
     231        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     232        return NULL;
     233    }
    211234    return array->data[position];
    212235}
  • trunk/psLib/src/types/psArray.h

    r4898 r5114  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-08-30 01:14:13 $
     14 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-09-24 00:17:44 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/types/psPixels.c

    r5101 r5114  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-23 00:04:36 $
     9 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-24 00:17:44 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    337337                 psPixelCoord value)
    338338{
    339     if (pixels == NULL)
     339    if (pixels == NULL) {
     340        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psPixels_NULL);
    340341        return false;
    341     if (position > pixels->n)
     342    }
     343    if (position > pixels->n) {
     344        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    342345        return false;
     346    }
    343347    if(position < 0)
    344348        position += pixels->n;
     349    if(position < 0) {
     350        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     351        return false;
     352    }
    345353    if (position == pixels->n) {
    346         if (position >= pixels->nalloc)
     354        if (position >= pixels->nalloc) {
     355            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     356                    "Specified position, %ld, is greater than n+1 of the pixels, %ld.",
     357                    position, pixels->nalloc);
    347358            return false;
     359        }
    348360        pixels->n++;
    349361    }
     
    359371    psPixelCoord out;
    360372    if (pixels == NULL) {
     373        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psPixels_NULL);
    361374        out.x = 0; //XXX: should be NAN when changed to float
    362375        out.y = 0; //XXX: should be NAN when changed to float
     
    364377    }
    365378    if (position >= pixels->n) {
     379        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    366380        out.x = 0; //XXX: should be NAN when changed to float
    367381        out.y = 0; //XXX: should be NAN when changed to float
     
    370384    if (position < 0)
    371385        position += pixels->n;
     386    if (position < 0) {
     387        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     388        out.x = 0; //XXX: should be NAN when changed to float
     389        out.y = 0; //XXX: should be NAN when changed to float
     390        return out;
     391    }
    372392    out.x = pixels->data[position].x;
    373393    out.y = pixels->data[position].y;
  • trunk/psLib/src/types/psPixels.h

    r5101 r5114  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-23 00:04:36 $
     9 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-24 00:17:44 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Note: See TracChangeset for help on using the changeset viewer.