IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1807


Ignore:
Timestamp:
Sep 14, 2004, 10:01:52 AM (22 years ago)
Author:
desonia
Message:

Updated files in src/collections to use new psError functionality. Also
cleaned up the code where needed, removing unnecessary error conditions,
etc.

Location:
trunk/psLib
Files:
2 added
21 deleted
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/psLib.kdevses

    r1761 r1807  
    22<!DOCTYPE KDevPrjSession>
    33<KDevPrjSession>
    4  <DocsAndViews NumberOfDocuments="5" >
    5   <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psCollectionsErrors.dat" >
    6    <View0 line="8" Type="???" >
    7     <AdditionalSettings Top="2" Width="1229" Attach="1" Height="705" Left="2" MinMaxMode="0" />
    8    </View0>
    9   </Doc0>
    10   <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/Makefile" >
    11    <View0 line="62" Type="???" >
    12     <AdditionalSettings Top="2" Width="1229" Attach="1" Height="705" Left="2" MinMaxMode="0" />
    13    </View0>
    14   </Doc1>
    15   <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/sysUtils/Makefile" >
    16    <View0 line="55" Type="???" >
    17     <AdditionalSettings Top="2" Width="1229" Attach="1" Height="705" Left="2" MinMaxMode="0" />
    18    </View0>
    19   </Doc2>
    20   <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psVector.c" >
    21    <View0 line="39" Type="???" >
    22     <AdditionalSettings Top="2" Width="1229" Attach="1" Height="705" Left="2" MinMaxMode="0" />
    23    </View0>
    24   </Doc3>
    25   <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psCollectionsErrors.h" >
    26    <View0 line="0" Type="???" >
    27     <AdditionalSettings Top="2" Width="1229" Attach="1" Height="705" Left="2" MinMaxMode="0" />
    28    </View0>
    29   </Doc4>
    30  </DocsAndViews>
     4 <DocsAndViews NumberOfDocuments="0" />
    315 <pluginList>
    326  <kdevbookmarks>
  • trunk/psLib/src/collections/psArray.c

    r1651 r1807  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-08-27 23:54:33 $
     11 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-14 20:01:52 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psArray.h"
    2727#include "psLogMsg.h"
     28
     29#include "psCollectionsErrors.h"
    2830
    2931/*****************************************************************************/
     
    4345    psArray* psArr = NULL;
    4446
    45     // Invalid nalloc
    46     if (nalloc < 1) {
    47         psError(__func__, "Invalid value for nalloc. nalloc: %d\n", nalloc);
    48         return NULL;
    49     }
    5047    // Create vector struct
    5148    psArr = (psArray* ) psAlloc(sizeof(psArray));
     
    6360psArray* psArrayRealloc(unsigned int nalloc, psArray* restrict in)
    6461{
    65     // Invalid nalloc
    66     if (nalloc < 1) {
    67         psError(__func__, "Invalid value for realloc (%d)\n", nalloc);
    68         return NULL;
    69     }
    70 
    7162    if (in == NULL) {
    7263        return psArrayAlloc(nalloc);
  • trunk/psLib/src/collections/psBitSet.c

    r1440 r1807  
    1 
    21/** @file  psBitSet.c
    32 *
     
    109 *
    1110 *  @author Ross Harman, MHPCC
    12  *
    13  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-08-09 23:34:57 $
     11 *  @author Robert DeSonia, MHPCC
     12 *
     13 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-14 20:01:52 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1717 */
    1818
    19 /******************************************************************************/
    20 
    21 /*  INCLUDE FILES                                                             */
    22 
    23 /******************************************************************************/
    2419#include <string.h>
    2520#include <stdio.h>
     
    3227#include "psError.h"
    3328#include "psAbort.h"
    34 
    35 /******************************************************************************/
    36 
    37 /*  DEFINE STATEMENTS                                                         */
    38 
    39 /******************************************************************************/
    40 
    41 // None
    42 
    43 /******************************************************************************/
    44 
    45 /*  TYPE DEFINITIONS                                                          */
    46 
    47 /******************************************************************************/
    48 
    49 // None
    50 
    51 /*****************************************************************************/
    52 
    53 /*  GLOBAL VARIABLES                                                         */
    54 
    55 /*****************************************************************************/
    56 
    57 // None
    58 
    59 /*****************************************************************************/
    60 
    61 /*  FILE STATIC VARIABLES                                                    */
    62 
    63 /*****************************************************************************/
    64 
    65 // None
    66 
    67 /*****************************************************************************/
    68 
    69 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    70 
    71 /*****************************************************************************/
    72 static void psBitSetFree(psBitSet* restrict inBitSet);
     29#include "psString.h"
     30
     31#include "psCollectionsErrors.h"
     32
     33enum {
     34    UNKNOWN_OP,
     35    AND_OP,
     36    OR_OP,
     37    XOR_OP,
     38    NOT_OP
     39};
     40
     41static void bitSetFree(psBitSet* restrict inBitSet);
    7342
    7443/** Private function to create a mask.
     
    9059}
    9160
    92 /*****************************************************************************/
    93 
    94 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    95 
    96 /*****************************************************************************/
     61static void bitSetFree(psBitSet* restrict inBitSet)
     62{
     63    if (inBitSet == NULL) {
     64        return;
     65    }
     66    psFree(inBitSet->bits);
     67}
     68
    9769psBitSet* psBitSetAlloc(int n)
    9870{
     
    10072    psBitSet* newObj = NULL;
    10173
    102     if (n <= 0) {
    103         psError(__func__, " : Line %d - Allocation size must be > 0: size = %d", __LINE__, n);
    104         return 0;
     74    if (n < 0) {
     75        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc",
     76                   PS_ERR_BAD_PARAMETER_VALUE, true,
     77                   PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
     78                   n);
     79        return NULL;
    10580    }
    10681
    10782    numBytes = ceil(n / 8.0);
    10883    newObj = psAlloc(sizeof(psBitSet));
    109     if (newObj == NULL) {
    110         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    111     }
    112     p_psMemSetDeallocator(newObj, (psFreeFcn) psBitSetFree);
     84    p_psMemSetDeallocator(newObj, (psFreeFcn) bitSetFree);
    11385    newObj->n = numBytes;
    11486
     
    11688    /* @i@ */
    11789    newObj->bits = psAlloc(sizeof(char) * numBytes);
    118     if (newObj->bits == NULL) {
    119         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    120     }
    121 
    122     memset(newObj->bits, numBytes, 0);
     90
     91    memset(newObj->bits, 0, numBytes);
    12392
    12493    return newObj;
    12594}
    12695
    127 static void psBitSetFree(psBitSet* restrict inBitSet)
    128 {
    129     if (inBitSet == NULL) {
    130         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
    131         return;
    132     }
    133     psFree(inBitSet->bits);
    134 }
    135 
    13696psBitSet* psBitSetSet(psBitSet* inBitSet, int bit)
    13797{
     
    13999
    140100    if (inBitSet == NULL) {
    141         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
     101        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
     102                   PS_ERR_BAD_PARAMETER_NULL, true,
     103                   PS_ERRORTEXT_psBitSet_SET_NULL);
    142104        return inBitSet;
    143     } else if (bit < 0) {
    144         psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
    145         return inBitSet;
    146     } else if (bit > inBitSet->n * 8 - 1) {
    147         psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
     105    } else if ( (bit < 0) ||
     106                (bit > inBitSet->n * 8 - 1) ) {
     107        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
     108                   PS_ERR_BAD_PARAMETER_VALUE, true,
     109                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     110                   bit,inBitSet->n * 8 - 1);
    148111        return inBitSet;
    149112    }
     
    155118}
    156119
     120psBitSet* psBitSetClear(psBitSet* inBitSet, int bit)
     121{
     122    char *byte = NULL;
     123
     124    if (inBitSet == NULL) {
     125        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
     126                   PS_ERR_BAD_PARAMETER_NULL, true,
     127                   PS_ERRORTEXT_psBitSet_SET_NULL);
     128        return inBitSet;
     129    } else if ( (bit < 0) ||
     130                (bit > inBitSet->n * 8 - 1) ) {
     131        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
     132                   PS_ERR_BAD_PARAMETER_VALUE, true,
     133                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     134                   bit,inBitSet->n * 8 - 1);
     135        return inBitSet;
     136    }
     137    // Variable byte is the byte in the array that contains the bit to be set
     138    byte = inBitSet->bits + bit / 8;
     139    *byte &= ! mask(bit);
     140
     141    return inBitSet;
     142}
     143
    157144bool psBitSetTest(const psBitSet* inBitSet, int bit)
    158145{
     
    160147
    161148    if (inBitSet == NULL) {
    162         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
    163         return 0;
    164     } else if (bit < 0) {
    165         psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
    166         return 0;
    167     } else if (bit > inBitSet->n * 8 - 1) {
    168         psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
    169         return 0;
    170     }
     149        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
     150                   PS_ERR_BAD_PARAMETER_NULL, true,
     151                   PS_ERRORTEXT_psBitSet_SET_NULL);
     152        return false;
     153    } else if ( (bit < 0) ||
     154                (bit > inBitSet->n * 8 - 1) ) {
     155        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
     156                   PS_ERR_BAD_PARAMETER_VALUE, true,
     157                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     158                   bit,inBitSet->n * 8 - 1);
     159        return false;
     160    }
     161
    171162    // Variable byte is the byte in the array that contains the bit to be tested
    172163    byte = inBitSet->bits + bit / 8;
    173     if ((int)(*byte & mask(bit)) == 0) {
    174         return 0;
    175     }
    176 
    177     return 1;
     164    return ((*byte & mask(bit)) != 0);
    178165}
    179166
     
    183170    int i = 0;
    184171    int n = 0;
    185     char tempChar = '0';
    186     char *outBits = NULL;
    187     char *inBits1 = NULL;
    188     char *inBits2 = NULL;
     172    char* outBits = NULL;
     173    char* inBits1 = NULL;
     174    char* inBits2 = NULL;
     175    int op = UNKNOWN_OP;
    189176
    190177    if (inBitSet1 == NULL) {
    191         psError(__func__, " : Line %d - Null psBitSet for inBitSet1 argument", __LINE__);
    192         return outBitSet;
    193     }
     178        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     179                   PS_ERR_BAD_PARAMETER_NULL, true,
     180                   PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
     181        psFree(outBitSet);
     182        return NULL;
     183    }
     184    inBits1 = inBitSet1->bits;
    194185
    195186    if (operator == NULL) {
    196         psError(__func__, " : Line %d - Null input operator\n", __LINE__);
    197         return outBitSet;
    198     }
    199 
    200     if (inBitSet2 == NULL) {
    201         psError(__func__, " : Line %d - Null psBitSet for inBitSet2 argument", __LINE__);
    202         return outBitSet;
     187        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     188                   PS_ERR_BAD_PARAMETER_NULL, true,
     189                   PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
     190        psFree(outBitSet);
     191        return NULL;
     192    }
     193
     194    // make operator all caps
     195    int tempStrLen = strlen(operator);
     196    char* tempStr = psAlloc(tempStrLen+1);
     197
     198    for (int lcv=0;lcv<tempStrLen;lcv++) {
     199        tempStr[lcv] = (char)toupper(operator[lcv]);
     200    }
     201    tempStr[tempStrLen] = '\0';
     202
     203    // parse the operator
     204    if (strcmp(operator,"AND")==0) {
     205        op = AND_OP;
     206    } else if (strcmp(operator,"OR")==0) {
     207        op = OR_OP;
     208    } else if (strcmp(operator,"XOR")==0) {
     209        op = XOR_OP;
     210    } else if (strcmp(operator,"NOT")==0) {
     211        op = NOT_OP;
     212    } else {
     213        psFree(tempStr);
     214        psFree(outBitSet);
     215        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     216                   PS_ERR_BAD_PARAMETER_VALUE, true,
     217                   PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
     218                   operator);
     219        return NULL;
     220    }
     221    psFree(tempStr);
     222
     223    if (op != NOT_OP) {
     224        if (inBitSet2 == NULL) {
     225            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     226                       PS_ERR_BAD_PARAMETER_NULL, true,
     227                       PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
     228            psFree(outBitSet);
     229            return NULL;
     230        }
     231
     232        if (inBitSet1->n != inBitSet2->n) {
     233            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     234                       PS_ERR_BAD_PARAMETER_SIZE, true,
     235                       PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
     236            psFree(outBitSet);
     237            return NULL;
     238        }
     239        inBits2 = inBitSet2->bits;
    203240    }
    204241
    205242    if (outBitSet == NULL) {
    206         outBitSet = psBitSetAlloc(inBitSet1->n * 8);
    207     }
    208 
    209     if (inBitSet1->n != inBitSet2->n || outBitSet->n != inBitSet1->n) {
    210         psError(__func__, " : Line %d - psBitSet sizes not the same", __LINE__);
    211         return outBitSet;
     243        outBitSet = psBitSetAlloc(inBitSet1->n*8);
     244    } else if (outBitSet->n != inBitSet1->n) {
     245        outBitSet->n = inBitSet1->n;
     246        outBitSet->bits = psRealloc(outBitSet->bits, inBitSet1->n);
    212247    }
    213248
    214249    n = outBitSet->n;
    215250    outBits = outBitSet->bits;
    216     inBits1 = inBitSet1->bits;
    217     inBits2 = inBitSet2->bits;
    218 
    219     tempChar = toupper(operator[0]);
    220     switch (tempChar) {
    221     case 'A':
     251
     252    switch (op) {
     253    case AND_OP:
    222254        for (i = 0; i < n; i++) {
    223255            outBits[i] = inBits1[i] & inBits2[i];
    224256        }
    225257        break;
    226     case 'O':
     258    case OR_OP:
    227259        for (i = 0; i < n; i++) {
    228260            outBits[i] = inBits1[i] | inBits2[i];
    229261        }
    230262        break;
    231     case 'X':
     263    case XOR_OP:
    232264        for (i = 0; i < n; i++) {
    233265            outBits[i] = inBits1[i] ^ inBits2[i];
    234266        }
    235267        break;
     268    case NOT_OP:
     269        for (i = 0; i < n; i++) {
     270            outBits[i] = ~inBits1[i];
     271        }
     272        break;
    236273    default:
    237         psError(__func__, " : Line %d - Invalid psBitMask binary operation: %s", __LINE__, operator);
     274        psAbort(PS_ERRORNAME_DOMAIN "psBitSetOp",
     275                "Unexpected error - operator parsed successfully but not valid?");
    238276    }
    239277
     
    243281psBitSet* psBitSetNot(psBitSet* outBitSet, const psBitSet* restrict inBitSet)
    244282{
    245     int i = 0;
    246     int n = 0;
    247     char *outBits = NULL;
    248     char *inBits = NULL;
    249 
    250     if (inBitSet == NULL) {
    251         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
    252         return outBitSet;
    253     }
    254 
    255     n = inBitSet->n;
    256     if (n == 0) {
    257         psError(__func__, " : Line %d - No elements in inBitSet", __LINE__);
    258         return outBitSet;
    259     }
     283    if (inBitSet == NULL) {
     284        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
     285                   PS_ERR_BAD_PARAMETER_NULL, true,
     286                   PS_ERRORTEXT_psBitSet_OPERAND_NULL);
     287        psFree(outBitSet);
     288        return NULL;
     289    }
     290
     291    outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
    260292
    261293    if (outBitSet == NULL) {
    262         outBitSet = psBitSetAlloc(n * 8);
    263     }
    264 
    265     if (inBitSet->n != outBitSet->n) {
    266         psError(__func__, " : Line %d - psBitSet sizes not the same", __LINE__);
    267         return outBitSet;
    268     }
    269 
    270     outBits = outBitSet->bits;
    271     inBits = inBitSet->bits;
    272 
    273     for (i = 0; i < n; i++) {
    274         outBits[i] = ~inBits[i];
     294        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
     295                   PS_ERR_UNKNOWN, false,
     296                   PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
    275297    }
    276298
     
    284306    char *outString = psAlloc((size_t) numBits + 1);
    285307
    286     if (outString == NULL) {
    287         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    288     }
    289 
    290308    for (i = 0; i < numBits; i++) {
    291         outString[numBits - i - 1] = (psBitSetTest(inBitSet, i) == 1) ? '1' : '0';
     309        outString[numBits - i - 1] = psBitSetTest(inBitSet, i) ? '1' : '0';
    292310    }
    293311
  • trunk/psLib/src/collections/psBitSet.h

    r1472 r1807  
    1 
    21/** @file  psBitSet.h
    32 *
     
    1312 *  @author Ross Harman, MHPCC
    1413 *
    15  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2004-08-11 19:53:33 $
     14 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-14 20:01:52 $
    1716 *
    1817 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2625
    2726/******************************************************************************/
    28 
    2927/*  TYPE DEFINITIONS                                                          */
    30 
    3128/******************************************************************************/
    3229
     
    4441
    4542/*****************************************************************************/
    46 
    4743/* FUNCTION PROTOTYPES                                                       */
    48 
    4944/*****************************************************************************/
    5045
     
    6459/** Set a bit.
    6560 *
    66  *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the
     61 *  Sets a bit at a given bit location. The bit is set based on a zero index with the
    6762 *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
    6863 *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
     
    7469    psBitSet* restrict inMask,         ///< Pointer to psBitSet to be set.
    7570    int bit                            ///< Bit to be set.
     71);
     72
     73/** Clear a bit.
     74 *
     75 *  Clear a bit at a given bit location. The bit is cleared based on a zero
     76 *  index with the first bit set in the zero bit slot of the zero element of
     77 *  the byte array.
     78 *
     79 *  @return  psBitSet* : Pointer to struct containing psBitSet.
     80 */
     81psBitSet* psBitSetClear(
     82    /* @returned@ */
     83    psBitSet* restrict inMask,         ///< Pointer to psBitSet to be cleared.
     84    int bit                            ///< Bit to be cleared.
    7685);
    7786
  • trunk/psLib/src/collections/psCollectionsErrors.dat

    r1762 r1807  
    77#  N.B. in code, the ERRORNAME appears as PS_ERRORTEXT_ERRORNAME
    88####################################################################
    9 psVector_NALLOC_NOT_POSITIVE    Parameter nalloc (%d) must be positive.
     9#
     10psVector_REALLOC_NULL                  psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown.
     11psVector_SORT_NULL                     psVectorSort can not sort a NULL psVector.
     12psVector_UNSUPPORTED_TYPE              Input psVector is an unsupported type (%d).
     13#
     14psBitSet_ALLOC_NEG_SIZE                The number of bit in a psBitSet (%d) must be greater than zero.
     15psBitSet_SET_NULL                      Can not operate on a NULL psBitSet.
     16psBitSet_BIT_OUTOFRANGE                The specified bit position (%d) is invalid.  Position must be between 0 and %d.
     17psBitSet_OPERATOR_NULL                 Specified operator is NULL.  Must specify desired operator.
     18psBitSet_OPERATOR_INVALID              Specified operator, %s, is invalid.  Valid operators are AND, OR, and XOR.
     19psBitSet_FIRST_OPERAND_NULL            First psBitSet operand can not be NULL.
     20psBitSet_SECOND_OPERAND_NULL           Second psBitSet operand can not be NULL.
     21psBitSet_OPERANDS_SIZE_DIFFER          The psBitSet operand must be the same size.
     22psBitSet_NOT_OP_FAILED                 Could not perform NOT operation.
     23psBitSet_OPERAND_NULL                  Operand can not be NULL.
     24#
     25psScalar_UNSUPPORTED_TYPE              Specified datatype (%d) is unsupported by psScalar.
     26psScalar_COPY_NULL                     Can not copy a NULL psScalar.
  • trunk/psLib/src/collections/psCollectionsErrors.h

    r1787 r1807  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-11 00:43:54 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-14 20:01:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030
    3131//~Start #define PS_ERRORTEXT_$1 "$2"
    32 #define PS_ERRORTEXT_psVector_NALLOC_NOT_POSITIVE "Parameter nalloc (%d) must be positive"
     32#define PS_ERRORTEXT_psVector_REALLOC_NULL "psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown."
     33#define PS_ERRORTEXT_psVector_SORT_NULL "psVectorSort can not sort a NULL psVector."
     34#define PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE "Input psVector is an unsupported type (%d)."
     35#define PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE "The number of bit in a psBitSet (%d) must be greater than zero."
     36#define PS_ERRORTEXT_psBitSet_SET_NULL "Can not operate on a NULL psBitSet."
     37#define PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE "The specified bit position (%d) is invalid.  Position must be between 0 and %d."
     38#define PS_ERRORTEXT_psBitSet_OPERATOR_NULL "Specified operator is NULL.  Must specify desired operator."
     39#define PS_ERRORTEXT_psBitSet_OPERATOR_INVALID "Specified operator, %s, is invalid.  Valid operators are AND, OR, and XOR."
     40#define PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL "First psBitSet operand can not be NULL."
     41#define PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL "Second psBitSet operand can not be NULL."
     42#define PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER "The psBitSet operand must be the same size."
     43#define PS_ERRORTEXT_psBitSet_NOT_OP_FAILED "Could not perform NOT operation."
     44#define PS_ERRORTEXT_psBitSet_OPERAND_NULL "Operand can not be NULL."
     45#define PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE "Specified datatype (%d) is unsupported by psScalar."
     46#define PS_ERRORTEXT_psScalar_COPY_NULL "Can not copy a NULL psScalar."
    3347//~End
    3448
  • trunk/psLib/src/collections/psList.c

    r1747 r1807  
    1 
    21/** @file psList.c
    32 *  @brief Support for doubly linked lists
     
    76 *  @author Robert Daniel DeSonia, MHPCC
    87 *
    9  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-09 02:23:27 $
     8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-14 20:01:52 $
    1110 *
    1211 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2423#include "psTrace.h"
    2524#include "psLogMsg.h"
     25
     26#include "psCollectionsErrors.h"
    2627
    2728#define ITER_INIT_HEAD ((void *)1)         // next iteration should return head
  • trunk/psLib/src/collections/psScalar.c

    r1648 r1807  
    1 
    21/** @file  psScalar.c
    32 *
     
    98 *  @author Ross Harman, MHPCC
    109 *
    11  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-08-27 23:34:05 $
     10 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-09-14 20:01:52 $
    1312 *
    1413 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1514 */
    1615
    17 /******************************************************************************/
    18 
    19 /*  INCLUDE FILES                                                             */
    20 
    21 /******************************************************************************/
    2216#include "psMemory.h"
    2317#include "psError.h"
     
    2620#include "psAbort.h"
    2721
    28 /******************************************************************************/
     22#include "psCollectionsErrors.h"
    2923
    30 /*  DEFINE STATEMENTS                                                         */
    31 
    32 /******************************************************************************/
    33 
    34 // None
    35 
    36 /******************************************************************************/
    37 
    38 /*  TYPE DEFINITIONS                                                          */
    39 
    40 /******************************************************************************/
    41 
    42 // None
    43 
    44 /*****************************************************************************/
    45 
    46 /*  GLOBAL VARIABLES                                                         */
    47 
    48 /*****************************************************************************/
    49 
    50 // None
    51 
    52 /*****************************************************************************/
    53 
    54 /*  FILE STATIC VARIABLES                                                    */
    55 
    56 /*****************************************************************************/
    57 
    58 // None
    59 
    60 /*****************************************************************************/
    61 
    62 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    63 
    64 /*****************************************************************************/
    65 
    66 // None
    67 
    68 /*****************************************************************************/
    69 
    70 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    71 
    72 /*****************************************************************************/
    7324psScalar* psScalarAlloc(psC64 value, psElemType dataType)
    7425{
     
    7728    // Create scalar
    7829    scalar = (psScalar* ) psAlloc(sizeof(psScalar));
    79     if (scalar == NULL) {
    80         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    81     }
    8230
    8331    scalar->type.dimen = PS_DIMEN_SCALAR;
     
    12270        break;
    12371    default:
    124         psError(__func__, ": Line %d - Invalid PS_TYPE: %d", __LINE__, dataType);
     72        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc",
     73                   PS_ERR_BAD_PARAMETER_TYPE, true,
     74                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
     75                   dataType);
    12576    }
    12677
     
    13485
    13586    if (scalar == NULL) {
    136         psError(__func__, "Null scalar not allowed");
     87        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
     88                   PS_ERR_BAD_PARAMETER_NULL, true,
     89                   PS_ERRORTEXT_psScalar_COPY_NULL);
     90        return NULL;
    13791    }
    13892
     
    176130        break;
    177131    default:
    178         psError(__func__, ": Line %d - Invalid PS_TYPE: %d", __LINE__, dataType);
     132        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
     133                   PS_ERR_BAD_PARAMETER_TYPE, true,
     134                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
     135                   dataType);
    179136    }
    180137
  • trunk/psLib/src/collections/psVector.c

    r1761 r1807  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-09-09 21:59:03 $
     12*  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-09-14 20:01:52 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psLogMsg.h"
    2626#include "psCompare.h"
     27
    2728#include "psCollectionsErrors.h"
    2829
    2930static void vectorFree(psVector* restrict psVec);
     31
     32
     33static void vectorFree(psVector* restrict psVec)
     34{
     35    if (psVec == NULL) {
     36        return;
     37    }
     38
     39    psFree(psVec->data.V);
     40}
    3041
    3142// FUNCTION IMPLEMENTATION - PUBLIC
     
    3546    psVector* psVec = NULL;
    3647    int elementSize = 0;
    37 
    38     // Invalid nalloc
    39     if (nalloc < 1) {
    40         psError(__func__, "Invalid value for nalloc. nalloc: %d\n", nalloc);
    41         return NULL;
    42     }
    4348
    4449    elementSize = PSELEMTYPE_SIZEOF(elemType);
     
    6469    psElemType elemType;
    6570
    66     // Invalid nalloc
    67     if (nalloc < 1) {
    68         psError(__func__, "Invalid value for realloc (%d)\n", nalloc);
    69         return NULL;
    70     }
    71 
    7271    if (in == NULL) {
    73         psError(__func__, "Null input vector\n");
     72        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc",
     73                   PS_ERR_BAD_PARAMETER_NULL, true,
     74                   PS_ERRORTEXT_psVector_REALLOC_NULL);
    7475        return NULL;
    7576    } else if (in->nalloc != nalloc) {     // No need to realloc to same size
     
    101102        return in;
    102103    }
    103     // Invalid nalloc
    104     if (nalloc < 1) {
    105         psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
    106         psFree(in);
    107         return NULL;
    108     }
    109104
    110105    in->data.V = psRealloc(in->data.V, nalloc * PSELEMTYPE_SIZEOF(type));
     
    119114psVector* psVectorSort(psVector* restrict outVector, const psVector* restrict inVector)
    120115{
    121     int inN = 0;
    122     int outN = 0;
     116    int N = 0;
    123117    int elSize = 0;
    124118    void *inVec = NULL;
     
    127121
    128122    if (inVector == NULL) {
    129         psError(__func__, " : Line %d - Null input vector\n", __LINE__);
    130         return outVector;
     123        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
     124                   PS_ERR_BAD_PARAMETER_NULL, true,
     125                   PS_ERRORTEXT_psVector_SORT_NULL);
     126        psFree(outVector);
     127        return NULL;
    131128    }
    132129
    133130    inType = inVector->type.type;
    134     inN = inVector->n;
     131    N = inVector->n;
    135132    inVec = inVector->data.V;
    136133    elSize = PSELEMTYPE_SIZEOF(inType);
    137134
    138135    if (outVector == NULL) {
    139         outVector = psVectorAlloc(inN, inType);
    140         outVector->n = inVector->n;
    141     }
    142 
    143     outN = outVector->n;
     136        outVector = psVectorAlloc(N, inType);
     137    }
     138
     139    // check to see if output vector needs to be resized/retyped
     140    if ( (N > outVector->nalloc) ||
     141            (inType != outVector->type.type) ) {
     142        // reshape the output vector to match the input vector's size/type.
     143        outVector = psVectorRecycle(outVector,N,inType);
     144    }
     145    outVector->n = N;
    144146    outVec = outVector->data.V;
    145147
    146     if (inN != outN) {
    147         psError(__func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n",
    148                 __LINE__, inN, outN);
     148    if (N == 0) {
     149        // no need to sort anything, as there are no elements in input vector.
    149150        return outVector;
    150151    }
    151152
    152     if (inType != outVector->type.type) {
    153         psError(__func__, " : Line %d - Input and output vectors are not same type: in=%d out=%d\n", __LINE__,
    154                 inType, outVector->type.type);
    155         return outVector;
    156     }
    157 
    158     if (inN == 0) {
    159         psError(__func__, " : Line %d - No elements in use for input vector\n", __LINE__);
    160         return outVector;
    161     }
    162 
    163     if (outN == 0) {
    164         psError(__func__, " : Line %d - No elements in use for output vector\n", __LINE__);
    165         return outVector;
    166     }
    167     // Copy input vector values into output vector
    168     memcpy(outVec, inVec, elSize * outN);
     153    // Copy input vector values into output vector if not in-place sorting
     154    if (inVector != outVector) {
     155        memcpy(outVec, inVec, elSize * N);
     156    }
    169157
    170158    // Sort output vector
    171159    switch (inType) {
    172160    case PS_TYPE_U8:
    173         qsort(outVec, inN, elSize, psCompareU8);
     161        qsort(outVec, N, elSize, psCompareU8);
    174162        break;
    175163    case PS_TYPE_U16:
    176         qsort(outVec, inN, elSize, psCompareU16);
     164        qsort(outVec, N, elSize, psCompareU16);
    177165        break;
    178166    case PS_TYPE_U32:
    179         qsort(outVec, inN, elSize, psCompareU32);
     167        qsort(outVec, N, elSize, psCompareU32);
    180168        break;
    181169    case PS_TYPE_U64:
    182         qsort(outVec, inN, elSize, psCompareU64);
     170        qsort(outVec, N, elSize, psCompareU64);
    183171        break;
    184172    case PS_TYPE_S8:
    185         qsort(outVec, inN, elSize, psCompareS8);
     173        qsort(outVec, N, elSize, psCompareS8);
    186174        break;
    187175    case PS_TYPE_S16:
    188         qsort(outVec, inN, elSize, psCompareS16);
     176        qsort(outVec, N, elSize, psCompareS16);
    189177        break;
    190178    case PS_TYPE_S32:
    191         qsort(outVec, inN, elSize, psCompareS32);
     179        qsort(outVec, N, elSize, psCompareS32);
    192180        break;
    193181    case PS_TYPE_S64:
    194         qsort(outVec, inN, elSize, psCompareS64);
     182        qsort(outVec, N, elSize, psCompareS64);
    195183        break;
    196184    case PS_TYPE_F32:
    197         qsort(outVec, inN, elSize, psCompareF32);
     185        qsort(outVec, N, elSize, psCompareF32);
    198186        break;
    199187    case PS_TYPE_F64:
    200         qsort(outVec, inN, elSize, psCompareF64);
     188        qsort(outVec, N, elSize, psCompareF64);
    201189        break;
    202190    default:
    203         psError(__func__, " : Line %d - Invalid psType\n", __LINE__);
     191        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
     192                   PS_ERR_BAD_PARAMETER_TYPE, true,
     193                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     194                   inType);
    204195    }
    205196
     
    207198}
    208199
    209 #define SORT_INDICES(TYPE)                                                                                   \
    210 for(i=0; i<inN; i++) {                                                                                       \
    211     for(j=0; j<inN; j++) {                                                                                   \
    212         diff = fabs((double)tmpVector->data.TYPE[i] - inVec[j]);                                             \
    213         if(diff < FLT_EPSILON) {                                                                             \
    214             outVec[i] = j;                                                                                   \
    215             break;                                                                                           \
    216         }                                                                                                    \
    217     }                                                                                                        \
    218 }
    219 
    220200psVector* psVectorSortIndex(psVector* restrict outVector, const psVector* restrict inVector)
    221201{
    222     int inN = 0;
    223     int outN = 0;
    224     int i = 0;
    225     int j = 0;
    226     float *inVec = NULL;
    227     int *outVec = NULL;
    228     double diff = 0.0f;
     202    int N = 0;
    229203    psVector* tmpVector = NULL;
    230204    psElemType inType = 0;
     205    psU32* outVec;
    231206
    232207    if (inVector == NULL) {
    233         psError(__func__, " : Line %d - Null input vector\n", __LINE__);
     208        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
     209                   PS_ERR_BAD_PARAMETER_NULL, true,
     210                   PS_ERRORTEXT_psVector_SORT_NULL);
     211        psFree(outVector);
     212        return NULL;
     213    }
     214
     215    N = inVector->n;
     216
     217    if (outVector == NULL) {
     218        outVector = psVectorAlloc(N, PS_TYPE_U32);
     219    }
     220
     221    // check to see if output vector needs to be resized/retyped
     222    if ( (N > outVector->nalloc) ||
     223            (outVector->type.type != PS_TYPE_U32) ) {
     224        // reshape the output vector to match the input vector's size/type.
     225        outVector = psVectorRecycle(outVector,N,PS_TYPE_U32);
     226    }
     227    outVector->n = N;
     228    outVec = outVector->data.U32;
     229
     230    if (N == 0) {
     231        // no need to sort anything, as there are no elements in input vector.
    234232        return outVector;
    235233    }
    236234
    237     inN = inVector->n;
    238     inVec = inVector->data.V;
    239     inType = inVector->type.type;
    240 
    241     if (outVector == NULL) {
    242         outVector = psVectorAlloc(inN, PS_TYPE_U32);
    243         outVector->n = inN;
    244     }
    245 
    246     outN = outVector->n;
    247     outVec = outVector->data.V;
    248 
    249     if (inN != outN) {
    250         psError(__func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n",
    251                 __LINE__, inN, outN);
    252         return outVector;
    253     }
    254 
    255     if (outVector->type.type != PS_TYPE_U32) {
    256         psError(__func__, " : Line %d - Output vector is not of type U32: out=%d\n",
    257                 __LINE__, outVector->type.type);
    258         return outVector;
    259     }
    260 
    261     tmpVector = psVectorAlloc(inN, inType);
    262     tmpVector->n = inN;
    263235    tmpVector = psVectorSort(tmpVector, inVector);
     236
     237    #define SORT_INDICES(TYPE,absfcn,maxError) {                              \
     238        ps##TYPE* inVec = inVector->data.TYPE;                                \
     239        ps##TYPE* tmpVec = tmpVector->data.TYPE;                              \
     240        ps##TYPE  diff;                                                       \
     241        for(int i=0; i<N; i++) {                                              \
     242            for(int j=0; j<N; j++) {                                          \
     243                diff = absfcn(tmpVec[i] - inVec[j]);                          \
     244                if(diff < maxError) {                                         \
     245                    outVec[i] = j;                                            \
     246                    break;                                                    \
     247                }                                                             \
     248            }                                                                 \
     249        }                                                                     \
     250    }
    264251
    265252    // Sort output vector
    266253    switch (inType) {
    267254    case PS_TYPE_U8:
    268         SORT_INDICES(U8);
     255        SORT_INDICES(U8,/* no absfcn needed */,1);
    269256        break;
    270257    case PS_TYPE_U16:
    271         SORT_INDICES(U16);
     258        SORT_INDICES(U16,/* no absfcn needed */,1);
    272259        break;
    273260    case PS_TYPE_U32:
    274         SORT_INDICES(U32);
     261        SORT_INDICES(U32,/* no absfcn needed */,1);
    275262        break;
    276263    case PS_TYPE_U64:
    277         SORT_INDICES(U64);
     264        SORT_INDICES(U64,/* no absfcn needed */,1);
    278265        break;
    279266    case PS_TYPE_S8:
    280         SORT_INDICES(S8);
     267        SORT_INDICES(S8,/* no absfcn needed */,1);
    281268        break;
    282269    case PS_TYPE_S16:
    283         SORT_INDICES(S16);
     270        SORT_INDICES(S16,/* no absfcn needed */,1);
    284271        break;
    285272    case PS_TYPE_S32:
    286         SORT_INDICES(S32);
     273        SORT_INDICES(S32,/* no absfcn needed */,1);
    287274        break;
    288275    case PS_TYPE_S64:
    289         SORT_INDICES(S64);
     276        SORT_INDICES(S64,/* no absfcn needed */,1);
    290277        break;
    291278    case PS_TYPE_F32:
    292         SORT_INDICES(F32);
     279        SORT_INDICES(F32,fabsf,FLT_EPSILON);
    293280        break;
    294281    case PS_TYPE_F64:
    295         SORT_INDICES(F64);
     282        SORT_INDICES(F64,fabs,DBL_EPSILON);
     283        break;
     284    case PS_TYPE_C32:
     285        SORT_INDICES(F64,cabsf,FLT_EPSILON);
     286        break;
     287    case PS_TYPE_C64:
     288        SORT_INDICES(F64,cabs,DBL_EPSILON);
    296289        break;
    297290    default:
    298         psError(__func__, " : Line %d - Invalid psType\n", __LINE__);
     291        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
     292                   PS_ERR_BAD_PARAMETER_TYPE, true,
     293                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     294                   inType);
    299295    }
    300296
     
    304300    return outVector;
    305301}
    306 
    307 static void vectorFree(psVector* restrict psVec)
    308 {
    309     if (psVec == NULL) {
    310         return;
    311     }
    312 
    313     psFree(psVec->data.V);
    314 }
  • trunk/psLib/src/mathtypes/psScalar.c

    r1648 r1807  
    1 
    21/** @file  psScalar.c
    32 *
     
    98 *  @author Ross Harman, MHPCC
    109 *
    11  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-08-27 23:34:05 $
     10 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-09-14 20:01:52 $
    1312 *
    1413 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1514 */
    1615
    17 /******************************************************************************/
    18 
    19 /*  INCLUDE FILES                                                             */
    20 
    21 /******************************************************************************/
    2216#include "psMemory.h"
    2317#include "psError.h"
     
    2620#include "psAbort.h"
    2721
    28 /******************************************************************************/
     22#include "psCollectionsErrors.h"
    2923
    30 /*  DEFINE STATEMENTS                                                         */
    31 
    32 /******************************************************************************/
    33 
    34 // None
    35 
    36 /******************************************************************************/
    37 
    38 /*  TYPE DEFINITIONS                                                          */
    39 
    40 /******************************************************************************/
    41 
    42 // None
    43 
    44 /*****************************************************************************/
    45 
    46 /*  GLOBAL VARIABLES                                                         */
    47 
    48 /*****************************************************************************/
    49 
    50 // None
    51 
    52 /*****************************************************************************/
    53 
    54 /*  FILE STATIC VARIABLES                                                    */
    55 
    56 /*****************************************************************************/
    57 
    58 // None
    59 
    60 /*****************************************************************************/
    61 
    62 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    63 
    64 /*****************************************************************************/
    65 
    66 // None
    67 
    68 /*****************************************************************************/
    69 
    70 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    71 
    72 /*****************************************************************************/
    7324psScalar* psScalarAlloc(psC64 value, psElemType dataType)
    7425{
     
    7728    // Create scalar
    7829    scalar = (psScalar* ) psAlloc(sizeof(psScalar));
    79     if (scalar == NULL) {
    80         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    81     }
    8230
    8331    scalar->type.dimen = PS_DIMEN_SCALAR;
     
    12270        break;
    12371    default:
    124         psError(__func__, ": Line %d - Invalid PS_TYPE: %d", __LINE__, dataType);
     72        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc",
     73                   PS_ERR_BAD_PARAMETER_TYPE, true,
     74                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
     75                   dataType);
    12576    }
    12677
     
    13485
    13586    if (scalar == NULL) {
    136         psError(__func__, "Null scalar not allowed");
     87        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
     88                   PS_ERR_BAD_PARAMETER_NULL, true,
     89                   PS_ERRORTEXT_psScalar_COPY_NULL);
     90        return NULL;
    13791    }
    13892
     
    176130        break;
    177131    default:
    178         psError(__func__, ": Line %d - Invalid PS_TYPE: %d", __LINE__, dataType);
     132        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
     133                   PS_ERR_BAD_PARAMETER_TYPE, true,
     134                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
     135                   dataType);
    179136    }
    180137
  • trunk/psLib/src/mathtypes/psVector.c

    r1761 r1807  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-09-09 21:59:03 $
     12*  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-09-14 20:01:52 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psLogMsg.h"
    2626#include "psCompare.h"
     27
    2728#include "psCollectionsErrors.h"
    2829
    2930static void vectorFree(psVector* restrict psVec);
     31
     32
     33static void vectorFree(psVector* restrict psVec)
     34{
     35    if (psVec == NULL) {
     36        return;
     37    }
     38
     39    psFree(psVec->data.V);
     40}
    3041
    3142// FUNCTION IMPLEMENTATION - PUBLIC
     
    3546    psVector* psVec = NULL;
    3647    int elementSize = 0;
    37 
    38     // Invalid nalloc
    39     if (nalloc < 1) {
    40         psError(__func__, "Invalid value for nalloc. nalloc: %d\n", nalloc);
    41         return NULL;
    42     }
    4348
    4449    elementSize = PSELEMTYPE_SIZEOF(elemType);
     
    6469    psElemType elemType;
    6570
    66     // Invalid nalloc
    67     if (nalloc < 1) {
    68         psError(__func__, "Invalid value for realloc (%d)\n", nalloc);
    69         return NULL;
    70     }
    71 
    7271    if (in == NULL) {
    73         psError(__func__, "Null input vector\n");
     72        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc",
     73                   PS_ERR_BAD_PARAMETER_NULL, true,
     74                   PS_ERRORTEXT_psVector_REALLOC_NULL);
    7475        return NULL;
    7576    } else if (in->nalloc != nalloc) {     // No need to realloc to same size
     
    101102        return in;
    102103    }
    103     // Invalid nalloc
    104     if (nalloc < 1) {
    105         psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
    106         psFree(in);
    107         return NULL;
    108     }
    109104
    110105    in->data.V = psRealloc(in->data.V, nalloc * PSELEMTYPE_SIZEOF(type));
     
    119114psVector* psVectorSort(psVector* restrict outVector, const psVector* restrict inVector)
    120115{
    121     int inN = 0;
    122     int outN = 0;
     116    int N = 0;
    123117    int elSize = 0;
    124118    void *inVec = NULL;
     
    127121
    128122    if (inVector == NULL) {
    129         psError(__func__, " : Line %d - Null input vector\n", __LINE__);
    130         return outVector;
     123        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
     124                   PS_ERR_BAD_PARAMETER_NULL, true,
     125                   PS_ERRORTEXT_psVector_SORT_NULL);
     126        psFree(outVector);
     127        return NULL;
    131128    }
    132129
    133130    inType = inVector->type.type;
    134     inN = inVector->n;
     131    N = inVector->n;
    135132    inVec = inVector->data.V;
    136133    elSize = PSELEMTYPE_SIZEOF(inType);
    137134
    138135    if (outVector == NULL) {
    139         outVector = psVectorAlloc(inN, inType);
    140         outVector->n = inVector->n;
    141     }
    142 
    143     outN = outVector->n;
     136        outVector = psVectorAlloc(N, inType);
     137    }
     138
     139    // check to see if output vector needs to be resized/retyped
     140    if ( (N > outVector->nalloc) ||
     141            (inType != outVector->type.type) ) {
     142        // reshape the output vector to match the input vector's size/type.
     143        outVector = psVectorRecycle(outVector,N,inType);
     144    }
     145    outVector->n = N;
    144146    outVec = outVector->data.V;
    145147
    146     if (inN != outN) {
    147         psError(__func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n",
    148                 __LINE__, inN, outN);
     148    if (N == 0) {
     149        // no need to sort anything, as there are no elements in input vector.
    149150        return outVector;
    150151    }
    151152
    152     if (inType != outVector->type.type) {
    153         psError(__func__, " : Line %d - Input and output vectors are not same type: in=%d out=%d\n", __LINE__,
    154                 inType, outVector->type.type);
    155         return outVector;
    156     }
    157 
    158     if (inN == 0) {
    159         psError(__func__, " : Line %d - No elements in use for input vector\n", __LINE__);
    160         return outVector;
    161     }
    162 
    163     if (outN == 0) {
    164         psError(__func__, " : Line %d - No elements in use for output vector\n", __LINE__);
    165         return outVector;
    166     }
    167     // Copy input vector values into output vector
    168     memcpy(outVec, inVec, elSize * outN);
     153    // Copy input vector values into output vector if not in-place sorting
     154    if (inVector != outVector) {
     155        memcpy(outVec, inVec, elSize * N);
     156    }
    169157
    170158    // Sort output vector
    171159    switch (inType) {
    172160    case PS_TYPE_U8:
    173         qsort(outVec, inN, elSize, psCompareU8);
     161        qsort(outVec, N, elSize, psCompareU8);
    174162        break;
    175163    case PS_TYPE_U16:
    176         qsort(outVec, inN, elSize, psCompareU16);
     164        qsort(outVec, N, elSize, psCompareU16);
    177165        break;
    178166    case PS_TYPE_U32:
    179         qsort(outVec, inN, elSize, psCompareU32);
     167        qsort(outVec, N, elSize, psCompareU32);
    180168        break;
    181169    case PS_TYPE_U64:
    182         qsort(outVec, inN, elSize, psCompareU64);
     170        qsort(outVec, N, elSize, psCompareU64);
    183171        break;
    184172    case PS_TYPE_S8:
    185         qsort(outVec, inN, elSize, psCompareS8);
     173        qsort(outVec, N, elSize, psCompareS8);
    186174        break;
    187175    case PS_TYPE_S16:
    188         qsort(outVec, inN, elSize, psCompareS16);
     176        qsort(outVec, N, elSize, psCompareS16);
    189177        break;
    190178    case PS_TYPE_S32:
    191         qsort(outVec, inN, elSize, psCompareS32);
     179        qsort(outVec, N, elSize, psCompareS32);
    192180        break;
    193181    case PS_TYPE_S64:
    194         qsort(outVec, inN, elSize, psCompareS64);
     182        qsort(outVec, N, elSize, psCompareS64);
    195183        break;
    196184    case PS_TYPE_F32:
    197         qsort(outVec, inN, elSize, psCompareF32);
     185        qsort(outVec, N, elSize, psCompareF32);
    198186        break;
    199187    case PS_TYPE_F64:
    200         qsort(outVec, inN, elSize, psCompareF64);
     188        qsort(outVec, N, elSize, psCompareF64);
    201189        break;
    202190    default:
    203         psError(__func__, " : Line %d - Invalid psType\n", __LINE__);
     191        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
     192                   PS_ERR_BAD_PARAMETER_TYPE, true,
     193                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     194                   inType);
    204195    }
    205196
     
    207198}
    208199
    209 #define SORT_INDICES(TYPE)                                                                                   \
    210 for(i=0; i<inN; i++) {                                                                                       \
    211     for(j=0; j<inN; j++) {                                                                                   \
    212         diff = fabs((double)tmpVector->data.TYPE[i] - inVec[j]);                                             \
    213         if(diff < FLT_EPSILON) {                                                                             \
    214             outVec[i] = j;                                                                                   \
    215             break;                                                                                           \
    216         }                                                                                                    \
    217     }                                                                                                        \
    218 }
    219 
    220200psVector* psVectorSortIndex(psVector* restrict outVector, const psVector* restrict inVector)
    221201{
    222     int inN = 0;
    223     int outN = 0;
    224     int i = 0;
    225     int j = 0;
    226     float *inVec = NULL;
    227     int *outVec = NULL;
    228     double diff = 0.0f;
     202    int N = 0;
    229203    psVector* tmpVector = NULL;
    230204    psElemType inType = 0;
     205    psU32* outVec;
    231206
    232207    if (inVector == NULL) {
    233         psError(__func__, " : Line %d - Null input vector\n", __LINE__);
     208        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
     209                   PS_ERR_BAD_PARAMETER_NULL, true,
     210                   PS_ERRORTEXT_psVector_SORT_NULL);
     211        psFree(outVector);
     212        return NULL;
     213    }
     214
     215    N = inVector->n;
     216
     217    if (outVector == NULL) {
     218        outVector = psVectorAlloc(N, PS_TYPE_U32);
     219    }
     220
     221    // check to see if output vector needs to be resized/retyped
     222    if ( (N > outVector->nalloc) ||
     223            (outVector->type.type != PS_TYPE_U32) ) {
     224        // reshape the output vector to match the input vector's size/type.
     225        outVector = psVectorRecycle(outVector,N,PS_TYPE_U32);
     226    }
     227    outVector->n = N;
     228    outVec = outVector->data.U32;
     229
     230    if (N == 0) {
     231        // no need to sort anything, as there are no elements in input vector.
    234232        return outVector;
    235233    }
    236234
    237     inN = inVector->n;
    238     inVec = inVector->data.V;
    239     inType = inVector->type.type;
    240 
    241     if (outVector == NULL) {
    242         outVector = psVectorAlloc(inN, PS_TYPE_U32);
    243         outVector->n = inN;
    244     }
    245 
    246     outN = outVector->n;
    247     outVec = outVector->data.V;
    248 
    249     if (inN != outN) {
    250         psError(__func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n",
    251                 __LINE__, inN, outN);
    252         return outVector;
    253     }
    254 
    255     if (outVector->type.type != PS_TYPE_U32) {
    256         psError(__func__, " : Line %d - Output vector is not of type U32: out=%d\n",
    257                 __LINE__, outVector->type.type);
    258         return outVector;
    259     }
    260 
    261     tmpVector = psVectorAlloc(inN, inType);
    262     tmpVector->n = inN;
    263235    tmpVector = psVectorSort(tmpVector, inVector);
     236
     237    #define SORT_INDICES(TYPE,absfcn,maxError) {                              \
     238        ps##TYPE* inVec = inVector->data.TYPE;                                \
     239        ps##TYPE* tmpVec = tmpVector->data.TYPE;                              \
     240        ps##TYPE  diff;                                                       \
     241        for(int i=0; i<N; i++) {                                              \
     242            for(int j=0; j<N; j++) {                                          \
     243                diff = absfcn(tmpVec[i] - inVec[j]);                          \
     244                if(diff < maxError) {                                         \
     245                    outVec[i] = j;                                            \
     246                    break;                                                    \
     247                }                                                             \
     248            }                                                                 \
     249        }                                                                     \
     250    }
    264251
    265252    // Sort output vector
    266253    switch (inType) {
    267254    case PS_TYPE_U8:
    268         SORT_INDICES(U8);
     255        SORT_INDICES(U8,/* no absfcn needed */,1);
    269256        break;
    270257    case PS_TYPE_U16:
    271         SORT_INDICES(U16);
     258        SORT_INDICES(U16,/* no absfcn needed */,1);
    272259        break;
    273260    case PS_TYPE_U32:
    274         SORT_INDICES(U32);
     261        SORT_INDICES(U32,/* no absfcn needed */,1);
    275262        break;
    276263    case PS_TYPE_U64:
    277         SORT_INDICES(U64);
     264        SORT_INDICES(U64,/* no absfcn needed */,1);
    278265        break;
    279266    case PS_TYPE_S8:
    280         SORT_INDICES(S8);
     267        SORT_INDICES(S8,/* no absfcn needed */,1);
    281268        break;
    282269    case PS_TYPE_S16:
    283         SORT_INDICES(S16);
     270        SORT_INDICES(S16,/* no absfcn needed */,1);
    284271        break;
    285272    case PS_TYPE_S32:
    286         SORT_INDICES(S32);
     273        SORT_INDICES(S32,/* no absfcn needed */,1);
    287274        break;
    288275    case PS_TYPE_S64:
    289         SORT_INDICES(S64);
     276        SORT_INDICES(S64,/* no absfcn needed */,1);
    290277        break;
    291278    case PS_TYPE_F32:
    292         SORT_INDICES(F32);
     279        SORT_INDICES(F32,fabsf,FLT_EPSILON);
    293280        break;
    294281    case PS_TYPE_F64:
    295         SORT_INDICES(F64);
     282        SORT_INDICES(F64,fabs,DBL_EPSILON);
     283        break;
     284    case PS_TYPE_C32:
     285        SORT_INDICES(F64,cabsf,FLT_EPSILON);
     286        break;
     287    case PS_TYPE_C64:
     288        SORT_INDICES(F64,cabs,DBL_EPSILON);
    296289        break;
    297290    default:
    298         psError(__func__, " : Line %d - Invalid psType\n", __LINE__);
     291        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
     292                   PS_ERR_BAD_PARAMETER_TYPE, true,
     293                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     294                   inType);
    299295    }
    300296
     
    304300    return outVector;
    305301}
    306 
    307 static void vectorFree(psVector* restrict psVec)
    308 {
    309     if (psVec == NULL) {
    310         return;
    311     }
    312 
    313     psFree(psVec->data.V);
    314 }
  • trunk/psLib/src/parseErrorCodes.pl

    r1748 r1807  
    3434    }
    3535    else {
    36         /^\s*(\w+)\s+([\%\w].*)/;
    37         my $ErrorCode        = $1;
    38         my $ErrorDescription = $2;
    39         print "  $ErrorCode: '$ErrorDescription'\n" if $verbose;
    40         push( @ErrorCodes,        $ErrorCode );
    41         push( @ErrorDescriptions, $ErrorDescription );
    42 
     36        if (/^\s*(\w+)\s+([\%\w].*)/) {
     37            my $ErrorCode        = $1;
     38            my $ErrorDescription = $2;
     39            print "  $ErrorCode: '$ErrorDescription'\n" if $verbose;
     40            push( @ErrorCodes,        $ErrorCode );
     41            push( @ErrorDescriptions, $ErrorDescription );
     42        } else {
     43            print "I $_\n" if $verbose;
     44        }
    4345    }
    4446}
  • trunk/psLib/src/psErrorCodes.dat

    r1764 r1807  
    1313MEMORY_DEREF_USAGE             dereferenced memory still used
    1414BAD_PARAMETER_VALUE            parameter is out-of-range
     15BAD_PARAMETER_TYPE             parameter is of unsupported data-type
    1516BAD_PARAMETER_NULL             parameter is null
    16 BAD_PARAMETER_LENGTH           parameter string is too long
     17BAD_PARAMETER_SIZE             size of parameter's data is outside of acceptable range.
    1718UNEXPECTED_NULL                unexpected NULL found
  • trunk/psLib/src/sys/psError.c

    r1696 r1807  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-07 19:05:07 $
     12 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-14 20:01:52 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9696    va_list argPtr;             // variable list arguement pointer
    9797
    98     // Get the variable list parameters to pass to logging function
    99     va_start(argPtr, fmt);
    100 
    101     // Call logging function with PS_LOG_ERROR level
    102     psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr);
    103 
    10498    if (new) {
    10599        psErrorClear();
    106100    }
    107101
     102    // Get the variable list parameters to pass to logging function
     103    va_start(argPtr, fmt);
     104
    108105    vsnprintf(errMsg,1024,fmt,argPtr);
    109106    err = psErrAlloc(name,code,errMsg);
    110107    pushErrorStack(err);
     108
     109    // Call logging function with PS_LOG_ERROR level
     110    psLogMsg(name, PS_LOG_ERROR, errMsg);
    111111
    112112    // Clean up stack after variable argument has been used
     
    116116}
    117117
    118 const psErr* psErrorGet(int which)
     118psErr* psErrorGet(int which)
    119119{
    120120    psErr* result;
     
    134134}
    135135
    136 const psErr* psErrorLast(void)
     136psErr* psErrorLast(void)
    137137{
    138138    return psErrorGet(0);
  • trunk/psLib/src/sys/psError.h

    r1783 r1807  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-09-10 23:20:35 $
     14 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-14 20:01:52 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050 *  @return    Error message object at 'which'
    5151 */
    52 const psErr* psErrorGet(
     52psErr* psErrorGet(
    5353    int which                          ///< position in the error stack. 0 is last error on stack.
    5454);
     
    6161 *  @return psErr*     Reference to last error message on error stack
    6262 */
    63 const psErr* psErrorLast(void);
     63psErr* psErrorLast(void);
    6464
    6565/** Clears the error stack.
  • trunk/psLib/src/sys/psErrorCodes.c

    r1787 r1807  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-11 00:43:54 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-14 20:01:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838            {PS_ERR_MEMORY_DEREF_USAGE,"dereferenced memory still used"},
    3939            {PS_ERR_BAD_PARAMETER_VALUE,"parameter is out-of-range"},
     40            {PS_ERR_BAD_PARAMETER_TYPE,"parameter is of unsupported data-type"},
    4041            {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
    41             {PS_ERR_BAD_PARAMETER_LENGTH,"parameter string is too long"},
     42            {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."},
    4243            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"},
    4344            //~End
  • trunk/psLib/src/sys/psErrorCodes.h

    r1787 r1807  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-11 00:43:54 $
     9 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-14 20:01:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4747    PS_ERR_MEMORY_DEREF_USAGE,   ///< dereferenced memory still used
    4848    PS_ERR_BAD_PARAMETER_VALUE,   ///< parameter is out-of-range
     49    PS_ERR_BAD_PARAMETER_TYPE,   ///< parameter is of unsupported data-type
    4950    PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
    50     PS_ERR_BAD_PARAMETER_LENGTH,   ///< parameter string is too long
     51    PS_ERR_BAD_PARAMETER_SIZE,   ///< size of parameter's data is outside of acceptable range.
    5152    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL foun
    5253    //~End
  • trunk/psLib/src/sys/psLogMsg.c

    r1798 r1807  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-11 03:03:36 $
     13 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-14 20:01:52 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    383383    va_end(ap);
    384384}
     385void psWarning(const char* name, const char* fmt, ...)
     386{
     387    va_list ap;
     388
     389    va_start(ap, fmt);
     390    psLogMsgV(name, PS_LOG_WARN, fmt, ap);
     391    va_end(ap);
     392}
  • trunk/psLib/src/sys/psLogMsg.h

    r1798 r1807  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-11 03:03:36 $
     13 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-14 20:01:52 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9999};
    100100
     101/** Logs a warning message.
     102 *
     103 *  This procedure logs a message to the destination set by a prior
     104 *  call to psLogSetDestination(), This is equivalent to calling
     105 *  psLogMsg with a level of PS_LOG_WARN.
     106 *
     107 */
     108void psWarning(
     109    const char* name,
     110    const char* fmt,
     111    ...
     112);
     113
    101114/// @}
    102115
  • trunk/psLib/src/sysUtils/psError.c

    r1696 r1807  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-07 19:05:07 $
     12 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-14 20:01:52 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9696    va_list argPtr;             // variable list arguement pointer
    9797
    98     // Get the variable list parameters to pass to logging function
    99     va_start(argPtr, fmt);
    100 
    101     // Call logging function with PS_LOG_ERROR level
    102     psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr);
    103 
    10498    if (new) {
    10599        psErrorClear();
    106100    }
    107101
     102    // Get the variable list parameters to pass to logging function
     103    va_start(argPtr, fmt);
     104
    108105    vsnprintf(errMsg,1024,fmt,argPtr);
    109106    err = psErrAlloc(name,code,errMsg);
    110107    pushErrorStack(err);
     108
     109    // Call logging function with PS_LOG_ERROR level
     110    psLogMsg(name, PS_LOG_ERROR, errMsg);
    111111
    112112    // Clean up stack after variable argument has been used
     
    116116}
    117117
    118 const psErr* psErrorGet(int which)
     118psErr* psErrorGet(int which)
    119119{
    120120    psErr* result;
     
    134134}
    135135
    136 const psErr* psErrorLast(void)
     136psErr* psErrorLast(void)
    137137{
    138138    return psErrorGet(0);
  • trunk/psLib/src/sysUtils/psError.h

    r1783 r1807  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-09-10 23:20:35 $
     14 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-14 20:01:52 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050 *  @return    Error message object at 'which'
    5151 */
    52 const psErr* psErrorGet(
     52psErr* psErrorGet(
    5353    int which                          ///< position in the error stack. 0 is last error on stack.
    5454);
     
    6161 *  @return psErr*     Reference to last error message on error stack
    6262 */
    63 const psErr* psErrorLast(void);
     63psErr* psErrorLast(void);
    6464
    6565/** Clears the error stack.
  • trunk/psLib/src/sysUtils/psErrorCodes.c

    r1787 r1807  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-11 00:43:54 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-14 20:01:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838            {PS_ERR_MEMORY_DEREF_USAGE,"dereferenced memory still used"},
    3939            {PS_ERR_BAD_PARAMETER_VALUE,"parameter is out-of-range"},
     40            {PS_ERR_BAD_PARAMETER_TYPE,"parameter is of unsupported data-type"},
    4041            {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
    41             {PS_ERR_BAD_PARAMETER_LENGTH,"parameter string is too long"},
     42            {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."},
    4243            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"},
    4344            //~End
  • trunk/psLib/src/sysUtils/psErrorCodes.h

    r1787 r1807  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-11 00:43:54 $
     9 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-14 20:01:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4747    PS_ERR_MEMORY_DEREF_USAGE,   ///< dereferenced memory still used
    4848    PS_ERR_BAD_PARAMETER_VALUE,   ///< parameter is out-of-range
     49    PS_ERR_BAD_PARAMETER_TYPE,   ///< parameter is of unsupported data-type
    4950    PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
    50     PS_ERR_BAD_PARAMETER_LENGTH,   ///< parameter string is too long
     51    PS_ERR_BAD_PARAMETER_SIZE,   ///< size of parameter's data is outside of acceptable range.
    5152    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL foun
    5253    //~End
  • trunk/psLib/src/sysUtils/psLogMsg.c

    r1798 r1807  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-11 03:03:36 $
     13 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-14 20:01:52 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    383383    va_end(ap);
    384384}
     385void psWarning(const char* name, const char* fmt, ...)
     386{
     387    va_list ap;
     388
     389    va_start(ap, fmt);
     390    psLogMsgV(name, PS_LOG_WARN, fmt, ap);
     391    va_end(ap);
     392}
  • trunk/psLib/src/sysUtils/psLogMsg.h

    r1798 r1807  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-11 03:03:36 $
     13 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-14 20:01:52 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9999};
    100100
     101/** Logs a warning message.
     102 *
     103 *  This procedure logs a message to the destination set by a prior
     104 *  call to psLogSetDestination(), This is equivalent to calling
     105 *  psLogMsg with a level of PS_LOG_WARN.
     106 *
     107 */
     108void psWarning(
     109    const char* name,
     110    const char* fmt,
     111    ...
     112);
     113
    101114/// @}
    102115
  • trunk/psLib/src/types/psArray.c

    r1651 r1807  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-08-27 23:54:33 $
     11 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-14 20:01:52 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psArray.h"
    2727#include "psLogMsg.h"
     28
     29#include "psCollectionsErrors.h"
    2830
    2931/*****************************************************************************/
     
    4345    psArray* psArr = NULL;
    4446
    45     // Invalid nalloc
    46     if (nalloc < 1) {
    47         psError(__func__, "Invalid value for nalloc. nalloc: %d\n", nalloc);
    48         return NULL;
    49     }
    5047    // Create vector struct
    5148    psArr = (psArray* ) psAlloc(sizeof(psArray));
     
    6360psArray* psArrayRealloc(unsigned int nalloc, psArray* restrict in)
    6461{
    65     // Invalid nalloc
    66     if (nalloc < 1) {
    67         psError(__func__, "Invalid value for realloc (%d)\n", nalloc);
    68         return NULL;
    69     }
    70 
    7162    if (in == NULL) {
    7263        return psArrayAlloc(nalloc);
  • trunk/psLib/src/types/psBitSet.c

    r1440 r1807  
    1 
    21/** @file  psBitSet.c
    32 *
     
    109 *
    1110 *  @author Ross Harman, MHPCC
    12  *
    13  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-08-09 23:34:57 $
     11 *  @author Robert DeSonia, MHPCC
     12 *
     13 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-14 20:01:52 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1717 */
    1818
    19 /******************************************************************************/
    20 
    21 /*  INCLUDE FILES                                                             */
    22 
    23 /******************************************************************************/
    2419#include <string.h>
    2520#include <stdio.h>
     
    3227#include "psError.h"
    3328#include "psAbort.h"
    34 
    35 /******************************************************************************/
    36 
    37 /*  DEFINE STATEMENTS                                                         */
    38 
    39 /******************************************************************************/
    40 
    41 // None
    42 
    43 /******************************************************************************/
    44 
    45 /*  TYPE DEFINITIONS                                                          */
    46 
    47 /******************************************************************************/
    48 
    49 // None
    50 
    51 /*****************************************************************************/
    52 
    53 /*  GLOBAL VARIABLES                                                         */
    54 
    55 /*****************************************************************************/
    56 
    57 // None
    58 
    59 /*****************************************************************************/
    60 
    61 /*  FILE STATIC VARIABLES                                                    */
    62 
    63 /*****************************************************************************/
    64 
    65 // None
    66 
    67 /*****************************************************************************/
    68 
    69 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    70 
    71 /*****************************************************************************/
    72 static void psBitSetFree(psBitSet* restrict inBitSet);
     29#include "psString.h"
     30
     31#include "psCollectionsErrors.h"
     32
     33enum {
     34    UNKNOWN_OP,
     35    AND_OP,
     36    OR_OP,
     37    XOR_OP,
     38    NOT_OP
     39};
     40
     41static void bitSetFree(psBitSet* restrict inBitSet);
    7342
    7443/** Private function to create a mask.
     
    9059}
    9160
    92 /*****************************************************************************/
    93 
    94 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    95 
    96 /*****************************************************************************/
     61static void bitSetFree(psBitSet* restrict inBitSet)
     62{
     63    if (inBitSet == NULL) {
     64        return;
     65    }
     66    psFree(inBitSet->bits);
     67}
     68
    9769psBitSet* psBitSetAlloc(int n)
    9870{
     
    10072    psBitSet* newObj = NULL;
    10173
    102     if (n <= 0) {
    103         psError(__func__, " : Line %d - Allocation size must be > 0: size = %d", __LINE__, n);
    104         return 0;
     74    if (n < 0) {
     75        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc",
     76                   PS_ERR_BAD_PARAMETER_VALUE, true,
     77                   PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
     78                   n);
     79        return NULL;
    10580    }
    10681
    10782    numBytes = ceil(n / 8.0);
    10883    newObj = psAlloc(sizeof(psBitSet));
    109     if (newObj == NULL) {
    110         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    111     }
    112     p_psMemSetDeallocator(newObj, (psFreeFcn) psBitSetFree);
     84    p_psMemSetDeallocator(newObj, (psFreeFcn) bitSetFree);
    11385    newObj->n = numBytes;
    11486
     
    11688    /* @i@ */
    11789    newObj->bits = psAlloc(sizeof(char) * numBytes);
    118     if (newObj->bits == NULL) {
    119         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    120     }
    121 
    122     memset(newObj->bits, numBytes, 0);
     90
     91    memset(newObj->bits, 0, numBytes);
    12392
    12493    return newObj;
    12594}
    12695
    127 static void psBitSetFree(psBitSet* restrict inBitSet)
    128 {
    129     if (inBitSet == NULL) {
    130         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
    131         return;
    132     }
    133     psFree(inBitSet->bits);
    134 }
    135 
    13696psBitSet* psBitSetSet(psBitSet* inBitSet, int bit)
    13797{
     
    13999
    140100    if (inBitSet == NULL) {
    141         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
     101        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
     102                   PS_ERR_BAD_PARAMETER_NULL, true,
     103                   PS_ERRORTEXT_psBitSet_SET_NULL);
    142104        return inBitSet;
    143     } else if (bit < 0) {
    144         psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
    145         return inBitSet;
    146     } else if (bit > inBitSet->n * 8 - 1) {
    147         psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
     105    } else if ( (bit < 0) ||
     106                (bit > inBitSet->n * 8 - 1) ) {
     107        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
     108                   PS_ERR_BAD_PARAMETER_VALUE, true,
     109                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     110                   bit,inBitSet->n * 8 - 1);
    148111        return inBitSet;
    149112    }
     
    155118}
    156119
     120psBitSet* psBitSetClear(psBitSet* inBitSet, int bit)
     121{
     122    char *byte = NULL;
     123
     124    if (inBitSet == NULL) {
     125        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
     126                   PS_ERR_BAD_PARAMETER_NULL, true,
     127                   PS_ERRORTEXT_psBitSet_SET_NULL);
     128        return inBitSet;
     129    } else if ( (bit < 0) ||
     130                (bit > inBitSet->n * 8 - 1) ) {
     131        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
     132                   PS_ERR_BAD_PARAMETER_VALUE, true,
     133                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     134                   bit,inBitSet->n * 8 - 1);
     135        return inBitSet;
     136    }
     137    // Variable byte is the byte in the array that contains the bit to be set
     138    byte = inBitSet->bits + bit / 8;
     139    *byte &= ! mask(bit);
     140
     141    return inBitSet;
     142}
     143
    157144bool psBitSetTest(const psBitSet* inBitSet, int bit)
    158145{
     
    160147
    161148    if (inBitSet == NULL) {
    162         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
    163         return 0;
    164     } else if (bit < 0) {
    165         psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit);
    166         return 0;
    167     } else if (bit > inBitSet->n * 8 - 1) {
    168         psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit);
    169         return 0;
    170     }
     149        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
     150                   PS_ERR_BAD_PARAMETER_NULL, true,
     151                   PS_ERRORTEXT_psBitSet_SET_NULL);
     152        return false;
     153    } else if ( (bit < 0) ||
     154                (bit > inBitSet->n * 8 - 1) ) {
     155        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
     156                   PS_ERR_BAD_PARAMETER_VALUE, true,
     157                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     158                   bit,inBitSet->n * 8 - 1);
     159        return false;
     160    }
     161
    171162    // Variable byte is the byte in the array that contains the bit to be tested
    172163    byte = inBitSet->bits + bit / 8;
    173     if ((int)(*byte & mask(bit)) == 0) {
    174         return 0;
    175     }
    176 
    177     return 1;
     164    return ((*byte & mask(bit)) != 0);
    178165}
    179166
     
    183170    int i = 0;
    184171    int n = 0;
    185     char tempChar = '0';
    186     char *outBits = NULL;
    187     char *inBits1 = NULL;
    188     char *inBits2 = NULL;
     172    char* outBits = NULL;
     173    char* inBits1 = NULL;
     174    char* inBits2 = NULL;
     175    int op = UNKNOWN_OP;
    189176
    190177    if (inBitSet1 == NULL) {
    191         psError(__func__, " : Line %d - Null psBitSet for inBitSet1 argument", __LINE__);
    192         return outBitSet;
    193     }
     178        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     179                   PS_ERR_BAD_PARAMETER_NULL, true,
     180                   PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
     181        psFree(outBitSet);
     182        return NULL;
     183    }
     184    inBits1 = inBitSet1->bits;
    194185
    195186    if (operator == NULL) {
    196         psError(__func__, " : Line %d - Null input operator\n", __LINE__);
    197         return outBitSet;
    198     }
    199 
    200     if (inBitSet2 == NULL) {
    201         psError(__func__, " : Line %d - Null psBitSet for inBitSet2 argument", __LINE__);
    202         return outBitSet;
     187        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     188                   PS_ERR_BAD_PARAMETER_NULL, true,
     189                   PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
     190        psFree(outBitSet);
     191        return NULL;
     192    }
     193
     194    // make operator all caps
     195    int tempStrLen = strlen(operator);
     196    char* tempStr = psAlloc(tempStrLen+1);
     197
     198    for (int lcv=0;lcv<tempStrLen;lcv++) {
     199        tempStr[lcv] = (char)toupper(operator[lcv]);
     200    }
     201    tempStr[tempStrLen] = '\0';
     202
     203    // parse the operator
     204    if (strcmp(operator,"AND")==0) {
     205        op = AND_OP;
     206    } else if (strcmp(operator,"OR")==0) {
     207        op = OR_OP;
     208    } else if (strcmp(operator,"XOR")==0) {
     209        op = XOR_OP;
     210    } else if (strcmp(operator,"NOT")==0) {
     211        op = NOT_OP;
     212    } else {
     213        psFree(tempStr);
     214        psFree(outBitSet);
     215        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     216                   PS_ERR_BAD_PARAMETER_VALUE, true,
     217                   PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
     218                   operator);
     219        return NULL;
     220    }
     221    psFree(tempStr);
     222
     223    if (op != NOT_OP) {
     224        if (inBitSet2 == NULL) {
     225            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     226                       PS_ERR_BAD_PARAMETER_NULL, true,
     227                       PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
     228            psFree(outBitSet);
     229            return NULL;
     230        }
     231
     232        if (inBitSet1->n != inBitSet2->n) {
     233            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
     234                       PS_ERR_BAD_PARAMETER_SIZE, true,
     235                       PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
     236            psFree(outBitSet);
     237            return NULL;
     238        }
     239        inBits2 = inBitSet2->bits;
    203240    }
    204241
    205242    if (outBitSet == NULL) {
    206         outBitSet = psBitSetAlloc(inBitSet1->n * 8);
    207     }
    208 
    209     if (inBitSet1->n != inBitSet2->n || outBitSet->n != inBitSet1->n) {
    210         psError(__func__, " : Line %d - psBitSet sizes not the same", __LINE__);
    211         return outBitSet;
     243        outBitSet = psBitSetAlloc(inBitSet1->n*8);
     244    } else if (outBitSet->n != inBitSet1->n) {
     245        outBitSet->n = inBitSet1->n;
     246        outBitSet->bits = psRealloc(outBitSet->bits, inBitSet1->n);
    212247    }
    213248
    214249    n = outBitSet->n;
    215250    outBits = outBitSet->bits;
    216     inBits1 = inBitSet1->bits;
    217     inBits2 = inBitSet2->bits;
    218 
    219     tempChar = toupper(operator[0]);
    220     switch (tempChar) {
    221     case 'A':
     251
     252    switch (op) {
     253    case AND_OP:
    222254        for (i = 0; i < n; i++) {
    223255            outBits[i] = inBits1[i] & inBits2[i];
    224256        }
    225257        break;
    226     case 'O':
     258    case OR_OP:
    227259        for (i = 0; i < n; i++) {
    228260            outBits[i] = inBits1[i] | inBits2[i];
    229261        }
    230262        break;
    231     case 'X':
     263    case XOR_OP:
    232264        for (i = 0; i < n; i++) {
    233265            outBits[i] = inBits1[i] ^ inBits2[i];
    234266        }
    235267        break;
     268    case NOT_OP:
     269        for (i = 0; i < n; i++) {
     270            outBits[i] = ~inBits1[i];
     271        }
     272        break;
    236273    default:
    237         psError(__func__, " : Line %d - Invalid psBitMask binary operation: %s", __LINE__, operator);
     274        psAbort(PS_ERRORNAME_DOMAIN "psBitSetOp",
     275                "Unexpected error - operator parsed successfully but not valid?");
    238276    }
    239277
     
    243281psBitSet* psBitSetNot(psBitSet* outBitSet, const psBitSet* restrict inBitSet)
    244282{
    245     int i = 0;
    246     int n = 0;
    247     char *outBits = NULL;
    248     char *inBits = NULL;
    249 
    250     if (inBitSet == NULL) {
    251         psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__);
    252         return outBitSet;
    253     }
    254 
    255     n = inBitSet->n;
    256     if (n == 0) {
    257         psError(__func__, " : Line %d - No elements in inBitSet", __LINE__);
    258         return outBitSet;
    259     }
     283    if (inBitSet == NULL) {
     284        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
     285                   PS_ERR_BAD_PARAMETER_NULL, true,
     286                   PS_ERRORTEXT_psBitSet_OPERAND_NULL);
     287        psFree(outBitSet);
     288        return NULL;
     289    }
     290
     291    outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
    260292
    261293    if (outBitSet == NULL) {
    262         outBitSet = psBitSetAlloc(n * 8);
    263     }
    264 
    265     if (inBitSet->n != outBitSet->n) {
    266         psError(__func__, " : Line %d - psBitSet sizes not the same", __LINE__);
    267         return outBitSet;
    268     }
    269 
    270     outBits = outBitSet->bits;
    271     inBits = inBitSet->bits;
    272 
    273     for (i = 0; i < n; i++) {
    274         outBits[i] = ~inBits[i];
     294        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
     295                   PS_ERR_UNKNOWN, false,
     296                   PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
    275297    }
    276298
     
    284306    char *outString = psAlloc((size_t) numBits + 1);
    285307
    286     if (outString == NULL) {
    287         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    288     }
    289 
    290308    for (i = 0; i < numBits; i++) {
    291         outString[numBits - i - 1] = (psBitSetTest(inBitSet, i) == 1) ? '1' : '0';
     309        outString[numBits - i - 1] = psBitSetTest(inBitSet, i) ? '1' : '0';
    292310    }
    293311
  • trunk/psLib/src/types/psBitSet.h

    r1472 r1807  
    1 
    21/** @file  psBitSet.h
    32 *
     
    1312 *  @author Ross Harman, MHPCC
    1413 *
    15  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2004-08-11 19:53:33 $
     14 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-14 20:01:52 $
    1716 *
    1817 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2625
    2726/******************************************************************************/
    28 
    2927/*  TYPE DEFINITIONS                                                          */
    30 
    3128/******************************************************************************/
    3229
     
    4441
    4542/*****************************************************************************/
    46 
    4743/* FUNCTION PROTOTYPES                                                       */
    48 
    4944/*****************************************************************************/
    5045
     
    6459/** Set a bit.
    6560 *
    66  *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the
     61 *  Sets a bit at a given bit location. The bit is set based on a zero index with the
    6762 *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
    6863 *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
     
    7469    psBitSet* restrict inMask,         ///< Pointer to psBitSet to be set.
    7570    int bit                            ///< Bit to be set.
     71);
     72
     73/** Clear a bit.
     74 *
     75 *  Clear a bit at a given bit location. The bit is cleared based on a zero
     76 *  index with the first bit set in the zero bit slot of the zero element of
     77 *  the byte array.
     78 *
     79 *  @return  psBitSet* : Pointer to struct containing psBitSet.
     80 */
     81psBitSet* psBitSetClear(
     82    /* @returned@ */
     83    psBitSet* restrict inMask,         ///< Pointer to psBitSet to be cleared.
     84    int bit                            ///< Bit to be cleared.
    7685);
    7786
  • trunk/psLib/src/types/psList.c

    r1747 r1807  
    1 
    21/** @file psList.c
    32 *  @brief Support for doubly linked lists
     
    76 *  @author Robert Daniel DeSonia, MHPCC
    87 *
    9  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-09 02:23:27 $
     8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-14 20:01:52 $
    1110 *
    1211 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2423#include "psTrace.h"
    2524#include "psLogMsg.h"
     25
     26#include "psCollectionsErrors.h"
    2627
    2728#define ITER_INIT_HEAD ((void *)1)         // next iteration should return head
  • trunk/psLib/test/collections/Makefile

    r1421 r1807  
    33##  Makefile:   test/collections
    44##
    5 ##  $Revision: 1.22 $  $Name: not supported by cvs2svn $
    6 ##  $Date: 2004-08-09 20:42:24 $
     5##  $Revision: 1.23 $  $Name: not supported by cvs2svn $
     6##  $Date: 2004-09-14 20:01:52 $
    77##
    88##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121TARGET = tst_psVector          \
    2222         tst_psArray           \
    23          tst_psBitSet_01       \
    24          tst_psBitSet_02       \
    25          tst_psBitSet_03       \
    26          tst_psBitSet_04       \
    27          tst_psBitSet_05       \
    28          tst_psBitSet_06       \
    29          tst_psBitSet_07       \
    30          tst_psBitSet_08       \
     23         tst_psBitSet          \
    3124         tst_psVectorSort_01   \
    3225         tst_psVectorSort_02   \
  • trunk/psLib/test/collections/verified/tst_psVector.stderr

    r1761 r1807  
    11<DATE><TIME>|<HOST>|I|main
    22    Following should be an error message.
    3 <DATE><TIME>|<HOST>|E|psVectorAlloc
    4     Invalid value for nalloc. nalloc: 0
    53<DATE><TIME>|<HOST>|I|main
    64    Following should be an error message.
    7 <DATE><TIME>|<HOST>|E|psVectorRealloc
    8     Null input vector
     5<DATE><TIME>|<HOST>|E|psLib.collections.psVectorRealloc
     6    psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown.
  • trunk/psLib/test/collections/verified/tst_psVectorSort_02.stderr

    r1304 r1807  
     1<DATE><TIME>|<HOST>|E|psLib.collections.psVectorSortIndex
     2    Input psVector is an unsupported type (0).
  • trunk/psLib/test/collections/verified/tst_psVectorSort_02.stdout

    r1304 r1807  
    1919\**********************************************************************************/
    2020
    21 arr[0] = 3
    22 arr[1] = 2
    23 arr[2] = 4
     21arr[0] = 0
     22arr[1] = 0
     23arr[2] = 0
    2424arr[3] = 0
    25 arr[4] = 1
     25arr[4] = 0
    2626
    2727---> TESTPOINT PASSED (psVectorSortIndex{Create sorted index vector} | tst_psVectorSort_02.c)
     
    4242\**********************************************************************************/
    4343
     44                   file:line ID
     45              psError.c:<LINENO>   9
     46              psError.c:<LINENO>   8
     47              psError.c:<LINENO>   7
     48ERROR: Found 3 memory leaks
    4449
    4550---> TESTPOINT PASSED (psVectorSort{Free vectors} | tst_psVectorSort_02.c)
  • trunk/psLib/test/collections/verified/tst_psVectorSort_03.stderr

    r1761 r1807  
    1 <DATE><TIME>|<HOST>|E|psVectorSort
    2      : Line <LINENO> - Input and output vector sizes are not equal: in=5 out=6
    3 <DATE><TIME>|<HOST>|E|psVectorSort
    4      : Line <LINENO> - Input and output vectors are not same type: in=1028 out=1032
  • trunk/psLib/test/collections/verified/tst_psVectorSort_04.stderr

    r1761 r1807  
    1 <DATE><TIME>|<HOST>|E|psVectorSort
    2      : Line <LINENO> - Null input vector
     1<DATE><TIME>|<HOST>|E|psLib.collections.psVectorSort
     2    psVectorSort can not sort a NULL psVector.
  • trunk/psLib/test/collections/verified/tst_psVectorSort_04.stdout

    r1233 r1807  
    1616\**********************************************************************************/
    1717
     18                   file:line ID
     19              psError.c:<LINENO>   5
     20              psError.c:<LINENO>   4
     21              psError.c:<LINENO>   3
     22ERROR: Found 3 memory blocks
    1823
    1924---> TESTPOINT PASSED (psVectorSort{Free arays} | tst_psVectorSort_04.c)
Note: See TracChangeset for help on using the changeset viewer.