IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12289


Ignore:
Timestamp:
Mar 6, 2007, 4:50:15 PM (19 years ago)
Author:
Paul Price
Message:

Adding additional type-specific assertions, and employing them where possible.

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

Legend:

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

    r11686 r12289  
    77 *  @author David Robbins, MHPCC
    88 *
    9  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-02-07 23:52:54 $
     9 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-03-07 02:50:15 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4141    PS_ASSERT_PTR_NON_NULL(argv, 2);
    4242    PS_ASSERT_PTR_NON_NULL(argc, 2);
     43    PS_ASSERT_INT_POSITIVE(*argc, 2);
    4344    int argnum = 0;   // Argument number
    4445
     
    9697                  const char *arg)
    9798{
     99    PS_ASSERT_INT_POSITIVE(argc, 0);
    98100    PS_ASSERT_PTR_NON_NULL(argv, 0);
    99     PS_ASSERT_PTR_NON_NULL(arg, 0);
    100     if (strlen(arg) == 0)
    101         return 0;
     101    PS_ASSERT_STRING_NON_EMPTY(arg, 0);
     102
    102103    for (int i = 1; i < argc; i++) {
    103104        if (!strcmp(argv[i], arg))
     
    113114                      char **argv)
    114115{
     116    PS_ASSERT_INT_POSITIVE(argnum, false);
     117    PS_ASSERT_PTR_NON_NULL(argc, false);
     118    PS_ASSERT_INT_LESS_THAN(argnum, *argc, false);
    115119    PS_ASSERT_PTR_NON_NULL(argv, false);
    116     PS_ASSERT_PTR_NON_NULL(argc, false);
    117     if (argnum > 0) {
    118         (*argc)--;
    119         for (int i = argnum; i < *argc; i++) {
    120             argv[i] = argv[i+1];
    121         }
    122         argv[*argc] = NULL;
    123     } else {
    124         return false;
    125     }
     120
     121    (*argc)--;
     122    for (int i = argnum; i < *argc; i++) {
     123        argv[i] = argv[i+1];
     124    }
     125    argv[*argc] = NULL;
    126126
    127127    return true;
     
    174174                     char **argv)
    175175{
    176     PS_ASSERT_PTR_NON_NULL(arguments, false);
     176    PS_ASSERT_METADATA_NON_NULL(arguments, false);
     177    PS_ASSERT_PTR_NON_NULL(argc, false);
     178    PS_ASSERT_INT_POSITIVE(*argc, false);
    177179    PS_ASSERT_PTR_NON_NULL(argv, false);
    178     PS_ASSERT_PTR_NON_NULL(argc, false);
    179     if (*argc < 1)
    180         return false;
     180
    181181    // We need to do a bit of mucking around in order to preserve the arguments metadata until the last
    182182    // minute --- if there is a bad argument, we need to return the old "arguments", since they contain
  • trunk/psLib/src/types/psArray.c

    r12171 r12289  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-03-02 02:34:45 $
     11 *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2007-03-07 02:50:15 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3333#include "psAssert.h"
    3434
    35 
     35#define DEFAULT_ARRAY_ADD 10            // Default number to add to an array when not specified
    3636
    3737/*****************************************************************************
     
    112112                          long nalloc)
    113113{
     114    PS_ASSERT_ARRAY_NON_NULL(in, NULL);
    114115    if (nalloc < 0) {
    115116        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     
    117118        return in;
    118119    }
    119     if (in == NULL) {
    120         psError(PS_ERR_BAD_PARAMETER_NULL,true,
    121                 _("psArrayRealloc must be given a non-NULL psArray to resize."));
    122         return NULL;
    123     } else if (in->nalloc != nalloc) {     // No need to realloc to same size
     120
     121    if (in->nalloc != nalloc) {     // No need to realloc to same size
    124122        if (nalloc < in->n) {
    125             for (psS32 i = nalloc; i < in->n; i++) {      // For reduction in vector size
     123            for (long i = nalloc; i < in->n; i++) {      // For reduction in vector size
    126124                psFree(in->data[i]);
    127125            }
     
    145143{
    146144    if (array == NULL) {
    147         int d = (delta > 0) ? delta : 10; // as spec'ed in SDRS.
     145        long d = (delta > 0) ? delta : DEFAULT_ARRAY_ADD;
    148146        array = psArrayAlloc(d);
    149147        array->n = 0;
     
    154152    if (n >= array->nalloc) {
    155153        // array needs to be expanded to make room for more elements
    156         int d = (delta > 0) ? delta : 10; // as spec'ed in SDRS.
     154        long d = (delta > 0) ? delta : DEFAULT_ARRAY_ADD;
    157155        array = psArrayRealloc(array, n+d);
    158156    }
     
    168166                       const psPtr data)
    169167{
     168    PS_ASSERT_ARRAY_NON_NULL(array, false);
     169    PS_ASSERT_PTR_NON_NULL(data, false);
     170
    170171    bool success = false;
    171 
    172     if (array == NULL) {
    173         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    174                 _("Specified psArray can not be NULL."));
    175         return false;
    176     }
    177 
    178     psS32 n = array->n;
    179     psPtr* psArrData = array->data;
    180     for (psS32 i = n-1; i >= 0; i--) {
    181         if (psArrData[i] == data) {
    182             memmove(&array->data[i],&array->data[i+1],(n-i-1)*sizeof(psPtr));
    183             psFree(data); // free the removed item (see Bug #449)
     172    long n = array->n;
     173    psPtr *arrayData = array->data;
     174    for (long i = n-1; i >= 0; i--) {
     175        if (arrayData[i] == data) {
     176            memmove(&arrayData[i],&arrayData[i+1],(n-i-1)*sizeof(psPtr));
     177            psFree(data); // Free the removed item
    184178            n--;
    185179            success = true;
     
    194188                        long index)
    195189{
    196     PS_ASSERT_PTR_NON_NULL(array, false);
    197 
     190    PS_ASSERT_ARRAY_NON_NULL(array, false);
    198191    if (index < 0 || index >= array->n) {
    199192        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    200                 _("index > then the number of elements in the array."));
     193                _("Specified index outside the range of elements in the array."));
    201194        return false;
    202195    }
     
    228221                     psComparePtrFunc func)
    229222{
    230     if (array == NULL) {
    231         return NULL;
    232     }
    233 
     223    PS_ASSERT_ARRAY_NON_NULL(array, NULL);
    234224    qsort(array->data, array->n, sizeof(psPtr), (int (*)(const void* , const void*))func);
    235 
    236225    return array;
    237226}
     
    242231                psPtr data)                        ///< the value to set it to
    243232{
    244     if (array == NULL)
    245     {
    246         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    247                 _("Specified psArray can not be NULL."));
    248         return false;
    249     }
     233    PS_ASSERT_ARRAY_NON_NULL(array, false);
    250234
    251235    if (position > array->n)
     
    257241    }
    258242
    259     if (position < 0)
     243    if (position < 0) {
    260244        position += array->n;
    261     if (position < 0)
    262     {
     245    }
     246    if (position < 0) {
    263247        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
    264248        return false;
    265249    }
    266250
    267     if (position == array->n)
    268     {
     251    if (position == array->n) {
    269252        if (position >= array->nalloc) {
    270253            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    285268                 long position )
    286269{
    287     if (array == NULL) {
    288         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    289                 _("Specified psArray can not be NULL."));
    290         return NULL;
    291     }
     270    PS_ASSERT_ARRAY_NON_NULL(array, NULL);
    292271
    293272    if (position >= array->n) {
     
    308287long psArrayLength(const psArray *array)
    309288{
    310     if ( !psMemCheckArray((psArray*)array) ) {
    311         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    312                 "Error:  Specified array is not a valid psArray \n");
    313         return -1;
    314     }
     289    PS_ASSERT_ARRAY_NON_NULL(array, -1);
    315290    return (array->n);
    316291}
  • trunk/psLib/src/types/psHash.c

    r11709 r12289  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2007-02-08 21:44:00 $
     14*  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2007-03-07 02:50:15 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3838static psHashBucket* hashBucketAlloc(const char *key, psPtr data, psHashBucket* next);
    3939static void hashBucketFree(psHashBucket* bucket);
    40 static psPtr doHashWork(psHash* table, const char *key, psPtr data, bool remove
    41                            );
     40static psPtr doHashWork(psHash* table, const char *key, psPtr data, bool remove);
    4241static void hashFree(psHash* table);
    4342
     
    5251psList* psHashKeyList(const psHash* hash)
    5352{
    54     PS_ASSERT_PTR_NON_NULL(hash, NULL);
    55     psS32 i = 0;                  // Loop index variable
     53    PS_ASSERT_HASH_NON_NULL(hash, NULL);
     54
    5655    psList* myLinkList = NULL;  // The output data structure
    5756    psHashBucket* ptr = NULL;   // Used to step thru linked list.
     
    6261    // Loop through every bucket in the hash table.  If that bucket is not
    6362    // NULL, then add the bucket's key to the linked list.
    64     for (i = 0; i < hash->n; i++) {
     63    for (long i = 0; i < hash->n; i++) {
    6564        if (hash->buckets[i] != NULL) {
    6665            // Since a bucket contains a linked list of keys/data, we must
     
    9392                                     psHashBucket* next)
    9493{
     94    assert(key && strlen(key) > 0);
     95
    9596    // Allocate memory for the new hash bucket.
    9697    psHashBucket* bucket = psAlloc(sizeof(psHashBucket));
     
    142143                      long nalloc)        // initial number of buckets
    143144{
    144     if (nalloc < 0)
    145     {
     145    if (nalloc < 0) {
    146146        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    147147                "Can't allocate a psHash of negative size.");
    148148        return NULL;
    149149    }
    150     psS32 i = 0;                  // loop index variable
    151150
    152151    // Create the new hash table.
     
    162161
    163162    // Initialize all buckets to NULL.
    164     for (i = 0; i < nalloc; i++)
    165     {
     163    for (long i = 0; i < nalloc; i++) {
    166164        table->buckets[i] = NULL;
    167165    }
     
    183181table.  It loops through each bucket, and calls hashBucketFree() on that
    184182bucket.
    185  
     183
    186184Inputs:
    187185    table: a hash table
     
    191189static void hashFree(psHash* table)
    192190{
    193     psS32 i = 0;                  // Loop index variable.
    194 
    195191    // Loop through each bucket in the hash table.  If that bucket is not
    196192    // NULL, then free the bucket via a function call to hashBucketFree();
    197     for (i = 0; i < table->n; i++) {
    198 
     193    for (long i = 0; i < table->n; i++) {
    199194        // A bucket is composed of a linked list of buckets.
    200195        while (table->buckets[i] != NULL) {
     
    223218Return:
    224219    NONE
    225  
     220
    226221NOTE: consider removing this private function and simply putting the code
    227222into the psHashInsert(), psHashLookup(), and psHashRemove().  Why?  Because
     
    234229                           )
    235230{
    236     psS64 hash = 1;          // This will contain an integer value
    237 
    238     // "hashed" from the key.
    239     char *tmpchar = NULL;       // Used in computing the hash function.
    240     psHashBucket* ptr = NULL;   // Used to retrieve the hash bucket.
    241     psHashBucket* optr = NULL;  // "original pointer": used to step
    242 
    243     // thru the linked list for a bucket.
    244 
    245     // The following condition should never be true, since this is a private
    246     // function, but I'm checking it anyway since future coders might change
    247     // the way this procedure is called.
    248     /*    if ((table == NULL) || (key == NULL)) {
    249         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    250         _("Input key can not be NULL."));
    251         return NULL;
    252     }
    253     */
    254     // NOTE: This is the originally supplied hash function.
    255     // for (psS32 i = 0, len = strlen(key); i < len; i++) {
    256     // hash = (hash << 1) ^ key[i];
    257     // }
    258     // hash &= (table->n - 1);
     231    assert(table);
     232    assert(table->n > 0);
     233    assert(key && strlen(key) > 0);
    259234
    260235    // This hash algorithm is from Sedgewick.  NOTE: must reread to ensure that
    261236    // the size of the hash table is not required to be a prime number.
    262     if (table->n <= 0)
    263         return NULL;
    264     tmpchar = (char *)key;
     237    char *tmpchar = (char *)key;        // Used in computing the hash function.
     238    long hash;                          // The hash value
    265239    for (hash = 0; *tmpchar != '\0'; tmpchar++) {
    266240        hash = (64 * hash + *tmpchar) % (table->n);
    267241    }
    268 
    269     // NOTE: This should not be necessary, but for now, I'm checking bounds
    270     // anyway.
    271     /*    if ((hash < 0) || (hash >= table->n)) {
    272         psError(PS_ERR_UNKNOWN, true,
    273         "Internal hash function out of range (%" PRId64 ")", hash);
    274     }
    275     */
     242    assert(hash >= 0 && hash < table->n);
     243
    276244    // ptr will have the correct hash bucket.
    277     ptr = table->buckets[hash];
     245    psHashBucket *ptr = table->buckets[hash];   // Used to retrieve the hash bucket.
     246    psHashBucket* optr = NULL;          // "original pointer": used to step thru the linked list for a bucket.
    278247
    279248    // We know the correct hash bucket, now we need to know what to do.
     
    281250    // or a remove operation on the hash table.
    282251
    283     if (data == NULL) {
    284         if (remove
    285            ) {
     252    if (data) {
     253        if (remove) {
    286254            // We search through the linked list for this bucket in
    287255            // the hash table and look for an entry for this key.
     
    368336               psPtr data)
    369337{
    370     PS_ASSERT_PTR_NON_NULL(hash, false);
    371     PS_ASSERT_PTR_NON_NULL(key, false);
     338    PS_ASSERT_HASH_NON_NULL(hash, false);
     339    PS_ASSERT_STRING_NON_EMPTY(key, false);
    372340    PS_ASSERT_PTR_NON_NULL(data, false);
    373341
     
    379347looks up the specified key in the hash table and returns the data associated
    380348with that key.
    381  
     349
    382350Inputs:
    383351    table: a hash table
     
    389357                   const char *key)     // key to lookup
    390358{
    391     PS_ASSERT_PTR_NON_NULL(hash, NULL);
    392     PS_ASSERT_PTR_NON_NULL(key, NULL);
     359    PS_ASSERT_HASH_NON_NULL(hash, NULL);
     360    PS_ASSERT_STRING_NON_EMPTY(key, NULL);
    393361
    394362    return doHashWork((psPtr)hash, key, NULL, false);
     
    407375                  const char *key)
    408376{
    409     PS_ASSERT_PTR_NON_NULL(hash, false);
    410     PS_ASSERT_PTR_NON_NULL(key, false);
     377    PS_ASSERT_HASH_NON_NULL(hash, false);
     378    PS_ASSERT_STRING_NON_EMPTY(key, false);
    411379
    412380    psPtr data = NULL;
     
    425393psArray* psHashToArray(const psHash* hash)
    426394{
    427     PS_ASSERT_PTR_NON_NULL(hash, NULL);
    428 
    429     // first, let's just count the number of data elements to know what size
    430     // psArray we need to allocate.
     395    PS_ASSERT_HASH_NON_NULL(hash, NULL);
     396
     397    // first, let's just count the number of data elements to know what size psArray we need to allocate.
    431398    int nElements = 0;
    432399    int nbucket = hash->n;
    433     //XXX:  If we do psArrayAlloc(0) here and use psArrayAdd(result, 1, tmpBucket->data)
    434     //we can eliminate the 2nd for loop below.
     400    // XXX:  If we do psArrayAlloc(0) here and use psArrayAdd(result, 1, tmpBucket->data)
     401    // we can eliminate the 2nd for loop below.
    435402    for (int i = 0; i < nbucket; i++) {
    436403        psHashBucket* tmpBucket = hash->buckets[i];
  • trunk/psLib/src/types/psHash.h

    r11709 r12289  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-02-08 21:44:00 $
     13 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2007-03-07 02:50:15 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4545}
    4646psHash;
    47 
    4847
    4948/** Checks the type of a particular pointer.
     
    114113
    115114
     115#define PS_ASSERT_HASH_NON_NULL(NAME, RVAL) \
     116if (!(NAME) || !(NAME)->buckets || (NAME)->n <= 0) { \
     117    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     118            "Error: Hash %s or one of its components is NULL.", \
     119            #NAME); \
     120    return RVAL; \
     121}
     122
    116123/// @} End of DataContainer Functions
    117124#endif // #ifndef PS_HASH_H
  • trunk/psLib/src/types/psList.c

    r11705 r12289  
    77 *  @author Joshua Hoblitt, University of Hawaii
    88 *
    9  *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-02-08 04:35:35 $
     9 *  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-03-07 02:50:15 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484static bool listIteratorRemove(psListIterator* iterator)
    8585{
    86     if (iterator == NULL || iterator->cursor == NULL) {
     86    assert(iterator);
     87    if (iterator->cursor == NULL) {
    8788        return false;
    8889    }
     
    159160                                    bool mutable)
    160161{
    161     if (list == NULL) {
    162         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    163                 _("Specified list is NULL."));
    164         return false;
    165     }
     162    PS_ASSERT_LIST_NON_NULL(list, NULL);
     163
    166164    psListIterator* iter = p_psAlloc(file, lineno, func, sizeof(psListIterator));
    167 
    168165    psMemSetDeallocator(iter, (psFreeFunc) listIteratorFree);
    169166
     
    180177    psMemDecrRefCounter(iter);
    181178
    182     if (! psListIteratorSet(iter,location)) {
     179    if (!psListIteratorSet(iter,location)) {
    183180        psFree(iter);
    184181        return NULL;
     
    191188                       long location)
    192189{
    193     if (iterator == NULL || iterator->list == NULL) {
    194         return false;
    195     }
     190    PS_ASSERT_LIST_ITERATOR_NON_NULL(iterator, false);
    196191
    197192    psList* list = iterator->list;
     
    260255               psPtr data)
    261256{
    262 
    263     if (list == NULL) {
    264         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    265                 _("Specified psList reference is NULL."));
    266         return false;
    267     }
    268 
    269     if (data == NULL) {
    270         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    271                 _("Specified data item is NULL."));
    272         return false;
    273     }
     257    PS_ASSERT_LIST_NON_NULL(list, false);
     258    PS_ASSERT_PTR_NON_NULL(data, false);
    274259
    275260    if (location > 0 && location >= (int)list->n) {
     
    297282                    void* data)
    298283{
    299     if (data == NULL) {
    300         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    301                 _("Specified data item is NULL."));
    302         return false;
    303     }
    304 
    305     if (iterator == NULL) {
    306         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    307                 _("Specified iterator is NULL."));
    308         return false;
    309     }
     284    PS_ASSERT_LIST_ITERATOR_NON_NULL(iterator, false);
     285    PS_ASSERT_PTR_NON_NULL(data, false);
    310286
    311287    // Check if the list pointed by the iterator can be changed
     
    318294    psListElem* cursor = iterator->cursor;
    319295    psList* list = iterator->list;
    320 
    321     if (cursor == NULL && list->head != NULL) {
    322         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    323                 _("Specified iterator is not valid."));
    324         return false;
    325     }
    326296
    327297    psListElem* elem = psAlloc(sizeof(psListElem));
     
    348318    list->n++;
    349319
    350     //XXX: The following is unreachable.  cursor can't == list->tail unless cursor->next == NULL.
    351     // in which case list->tail will be set to elem.  (list->tail = elem;)
    352     /*    if (cursor == list->tail) {
    353             list->tail = elem;
    354         }
    355     */
    356320    psArray* iterators = list->iterators;
    357321    int index = iterator->index;
     
    369333                     void* data)
    370334{
    371     if (data == NULL) {
    372         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    373                 _("Specified data item is NULL."));
    374         return false;
    375     }
    376 
    377     if (iterator == NULL) {
    378         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    379                 _("Specified iterator is NULL."));
    380         return false;
    381     }
     335    PS_ASSERT_LIST_ITERATOR_NON_NULL(iterator, false);
     336    PS_ASSERT_PTR_NON_NULL(data, false);
    382337
    383338    // Check if the list pointed by the iterator can be changed
     
    390345    psListElem* cursor = iterator->cursor;
    391346    psList* list = iterator->list;
    392 
    393     if (cursor == NULL && list->head != NULL) {
    394         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    395                 _("Specified iterator is not valid."));
    396         return false;
    397     }
    398 
    399347    psListElem* elem = psAlloc(sizeof(psListElem));
    400348
     
    420368    list->n++;
    421369
    422     //XXX: The following is unreachable.  cursor can't == list->head unless cursor->prev == NULL.
    423     // in which case list->head will be set to elem.  (list->tail = elem;)
    424     /*   if (cursor == list->head) {
    425             list->head = elem;
    426         }
    427     */
    428370    psArray* iterators = list->iterators;
    429371    int index = iterator->index;
     
    441383                  long location)
    442384{
    443     if (list == NULL) {
    444         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    445                 _("Specified psList reference is NULL."));
    446         return false;
    447     }
     385    PS_ASSERT_LIST_NON_NULL(list, false);
    448386
    449387    // move ourselves to the given position
     
    459397                      psPtr data)
    460398{
    461     if (list == NULL) {
    462         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    463                 _("Specified psList reference is NULL."));
    464         return false;
    465     }
    466 
    467     if (data == NULL) {
    468         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    469                 _("Specified data item is NULL."));
    470         return false;
    471     }
     399    PS_ASSERT_LIST_NON_NULL(list, false);
     400    PS_ASSERT_PTR_NON_NULL(data, false);
    472401
    473402    psListElem* elem = list->head;
     
    493422                long location)
    494423{
    495     if (list == NULL) {
    496         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    497                 _("Specified psList reference is NULL."));
    498         return NULL;
    499     }
    500 
    501     if (list->head == NULL) { // list empty?
    502         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    503                 _("Specified psList reference is empty."));
    504         return NULL;
    505     }
     424    PS_ASSERT_LIST_NON_NULL(list, NULL);
    506425
    507426    psListIterator* iterator = list->iterators->data[0];
     
    522441psPtr psListGetAndIncrement(psListIterator* iterator)
    523442{
    524     if (iterator == NULL ) {
    525         return NULL;
    526     }
     443    PS_ASSERT_LIST_ITERATOR_NON_NULL(iterator, NULL);
     444
    527445    if (( iterator->cursor == NULL) && (iterator->offEnd)) {
    528446        return NULL;
     
    547465psPtr psListGetAndDecrement(psListIterator* iterator)
    548466{
    549     if (iterator == NULL ) {
    550         return NULL;
    551     }
     467    PS_ASSERT_LIST_ITERATOR_NON_NULL(iterator, NULL);
     468
    552469    if ((iterator->cursor == NULL) && (!iterator->offEnd))  {
    553470        return NULL;
     
    573490psArray* psListToArray(const psList* list)
    574491{
    575     PS_ASSERT_PTR_NON_NULL(list, NULL);
     492    PS_ASSERT_LIST_NON_NULL(list, NULL);
    576493
    577494    long n = list->n;
     
    579496
    580497    psListElem *ptr = list->head;
    581     for (psS32 i = 0; i < n; i++) {
     498    for (long i = 0; i < n; i++) {
    582499        arr->data[i] = psMemIncrRefCounter(ptr->data);
    583500        ptr = ptr->next;
     
    589506psList* psArrayToList(const psArray* array)
    590507{
    591     psU32 n;
    592     psList* list;               // list of elements
    593 
    594     if (array == NULL) {
    595         return NULL;
    596     }
    597 
    598     list = psListAlloc(NULL);
    599     n = array->n;
    600     for (psS32 i = 0; i < n; i++) {
     508    PS_ASSERT_ARRAY_NON_NULL(array, NULL);
     509
     510    psList *list = psListAlloc(NULL);   // list of elements
     511    for (long i = 0; i < array->n; i++) {
    601512        psListAdd(list, PS_LIST_TAIL, array->data[i]);
    602513    }
    603 
    604514    return list;
    605515}
     
    608518                   psComparePtrFunc func)
    609519{
    610     psArray* arr;
    611 
    612     if (list == NULL) {
    613         return NULL;
    614     }
    615     if (func == NULL) {
    616         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    617                 _("Specified psComparePtrFunc is NULL."));
    618         return list;
    619     }
     520    PS_ASSERT_LIST_NON_NULL(list, NULL);
     521    PS_ASSERT_PTR_NON_NULL(func, NULL);
     522
    620523    // convert to indexable vector for use by qsort.
    621     arr = psListToArray(list);
    622     psArray* iterators = psMemIncrRefCounter(list->iterators);
     524    psArray *arr = psListToArray(list);
     525    psArray *iterators = psMemIncrRefCounter(list->iterators);
    623526    psFree(list);
    624527
     
    641544long psListLength(const psList *list)
    642545{
    643     if ( !psMemCheckList((psList*)list) ) {
    644         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    645                 "Error:  Specified list is not a valid psList \n");
    646         return -1;
    647     }
    648     return (list->n);
    649 }
    650 
    651 
     546    PS_ASSERT_LIST_NON_NULL(list, -1);
     547    return list->n;
     548}
     549
     550
  • trunk/psLib/src/types/psList.h

    r11705 r12289  
    55 *  @author Robert Daniel DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-02-08 04:35:35 $
     7 *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-03-07 02:50:15 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3434
    3535/** Doubly-linked list element */
    36 typedef struct psListElem
    37 {
     36typedef struct psListElem {
    3837    struct psListElem* prev;           ///< previous link in list
    3938    struct psListElem* next;           ///< next link in list
    4039    psPtr data;                        ///< real data item
    41 }
    42 psListElem;
     40} psListElem;
    4341
    4442
     
    4846 *  @see psListAlloc
    4947 */
    50 typedef struct
    51 {
     48typedef struct {
    5249    long n;                            ///< number of elements on list
    5350    psListElem* head;                  ///< first element on list (may be NULL)
     
    5855    ///< others are user-level iterators created by psListIteratorAlloc.
    5956    void *lock;                        ///< Optional lock for thread safety
    60 }
    61 psList;
     57} psList;
    6258
    6359
     
    279275
    280276
     277#define PS_ASSERT_LIST_NON_NULL(NAME, RVAL) \
     278if (!(NAME) || !(NAME)->iterators || (NAME)->n <= 0) { \
     279    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     280            "Error: List %s or one of its components is NULL.", \
     281            #NAME); \
     282    return RVAL; \
     283}
     284
     285#define PS_ASSERT_LIST_ITERATOR_NON_NULL(NAME, RVAL) \
     286if (!(NAME) || !(NAME)->list || !(NAME)->list->iterators || (NAME)->list->n <= 0 || \
     287    (!(NAME)->cursor && (NAME)->list->head) || (NAME)->index <= 0) { \
     288    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     289            "Error: List iterator %s or one of its components is NULL.", \
     290            #NAME); \
     291    return RVAL; \
     292}
     293
     294
    281295/// @} End of DataContainer Functions
    282296#endif // #ifndef PS_LIST_H
  • trunk/psLib/src/types/psLookupTable.h

    r11710 r12289  
    66*  @author Ross Harman, MHPCC
    77*
    8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2007-02-08 21:57:02 $
     8*  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2007-03-07 02:50:15 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222#include "psArray.h"
    2323#include "psLogMsg.h"
    24 
     24#include "psString.h"
    2525
    2626/** Lookup table structure
     
    2929 *
    3030 */
    31 typedef struct
    32 {
    33     const char *filename;              ///< Name of file with table
    34     const char *format;                ///< scanf-like format string for file
     31typedef struct {
     32    psString filename;                  ///< Name of file with table
     33    psString format;                    ///< scanf-like format string for file
    3534    long indexCol;                     ///< Column of the index vector (starting at zero)
    3635    psVector *index;                   ///< Vector of independent index values
     
    3837    const double validFrom;            ///< Lower bound for rable read
    3938    const double validTo;              ///< Upper bound for table read
     39} psLookupTable;
     40
     41#define PS_ASSERT_LOOKUPTABLE_NON_NULL(NAME, RVAL) \
     42if (!(NAME) || !(NAME)->filename || strlen((NAME)->filename) == 0 || \
     43    !(NAME)->format || strlen((NAME)->format) == 0 || (NAME)->index < 0) { \
     44    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     45            "Error: Lookup table %s or one of its components is NULL.", \
     46            #NAME); \
     47    return RVAL; \
    4048}
    41 psLookupTable;
    42 
    4349
    4450/** Lookup table lookup status and error conditions
     
    135141    const char *func,                   ///< Function name of caller
    136142    psLookupTable *table,               ///< Lookup table into which to import
    137     const psArray *vectors,             ///< Array of vectors
     143    psArray *vectors,                   ///< Array of vectors
    138144    long indexCol                       ///< Index of the index vector in the array of vectors
    139145);
  • trunk/psLib/src/types/psMetadata.c

    r12283 r12289  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.153 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2007-03-06 21:58:47 $
     14 *  @version $Revision: 1.154 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2007-03-07 02:50:15 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11591159{
    11601160    PS_ASSERT_METADATA_NON_NULL(md, NULL);
    1161 
    1162     psList *list = psListAlloc(NULL);   // List with the keys
    1163     psMetadataIterator *iter = psMetadataIteratorAlloc(md, PS_LIST_HEAD, false);
    1164     psMetadataItem *item;               // Item from iteration
    1165     while ((item = psMetadataGetAndIncrement(iter))) {
    1166         psListAdd(list, PS_LIST_TAIL, item->name);
    1167     }
    1168     return list;
     1161    return psHashKeyList(md->hash);
    11691162}
    11701163
  • trunk/psLib/src/types/psMetadataConfig.c

    r11668 r12289  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.128 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2007-02-06 21:36:09 $
     12*  @version $Revision: 1.129 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2007-03-07 02:50:15 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    449449
    450450    PS_ASSERT_PTR_NON_NULL(fd, false);
    451     PS_ASSERT_PTR_NON_NULL(format, false);
    452     PS_ASSERT_PTR_NON_NULL(item, false);
     451    PS_ASSERT_STRING_NON_EMPTY(format, false);
     452    PS_ASSERT_METADATA_ITEM_NON_NULL(item, false);
    453453
    454454    type = item->type;
     
    11521152                         psMetadataFlags flags)
    11531153{
    1154     PS_ASSERT_PTR_NON_NULL(keyName, false);
    1155     PS_ASSERT_PTR_NON_NULL(levelArray, false);
     1154    PS_ASSERT_STRING_NON_EMPTY(keyName, false);
     1155    PS_ASSERT_ARRAY_NON_NULL(levelArray, false);
    11561156    PS_ASSERT_PTR_NON_NULL(linePtr, false);
    11571157
     
    11821182                      psMetadataFlags flags)
    11831183{
    1184     PS_ASSERT_PTR_NON_NULL(keyName, false);
    1185     PS_ASSERT_PTR_NON_NULL(levelArray, false);
     1184    PS_ASSERT_STRING_NON_EMPTY(keyName, false);
     1185    PS_ASSERT_ARRAY_NON_NULL(levelArray, false);
    11861186    PS_ASSERT_PTR_NON_NULL(linePtr, false);
    11871187
     
    12471247                             psMetadataFlags flags)
    12481248{
    1249     PS_ASSERT_PTR_NON_NULL(keyName, false);
    1250     PS_ASSERT_PTR_NON_NULL(levelArray, false);
     1249    PS_ASSERT_STRING_NON_EMPTY(keyName, false);
     1250    PS_ASSERT_ARRAY_NON_NULL(levelArray, false);
    12511251    PS_ASSERT_PTR_NON_NULL(linePtr, false);
    12521252
     
    12741274{
    12751275    // Check for NULL file name
    1276     PS_ASSERT_PTR_NON_NULL(filename, NULL);
     1276    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    12771277
    12781278    // Attempt to open specified file
     
    13571357    bool allocedMD = false;
    13581358
    1359     PS_ASSERT_PTR_NON_NULL(str, NULL);
     1359    PS_ASSERT_STRING_NON_EMPTY(str, NULL);
    13601360
    13611361    // Initialise nFail, if provided
     
    14301430psString psMetadataConfigFormat(psMetadata *md)
    14311431{
    1432     PS_ASSERT_PTR_NON_NULL(md, NULL);
     1432    PS_ASSERT_METADATA_NON_NULL(md, NULL);
    14331433
    14341434    psString format = NULL;
     
    14651465static psString formatMetadataItem(psMetadataItem *item)
    14661466{
    1467     PS_ASSERT_PTR_NON_NULL(item, NULL);
     1467    PS_ASSERT_METADATA_ITEM_NON_NULL(item, NULL);
    14681468
    14691469    psString content = NULL;
     
    16981698static psArray *p_psMetadataKeyArray(psMetadata *md)
    16991699{
    1700     PS_ASSERT_PTR_NON_NULL(md, NULL);
     1700    PS_ASSERT_METADATA_NON_NULL(md, NULL);
    17011701
    17021702    psArray *keys = psArrayAllocEmpty(psListLength(md->list));
     
    17321732                           const char *filename)
    17331733{
    1734     PS_ASSERT_PTR_NON_NULL(md, NULL);
    1735     PS_ASSERT_PTR_NON_NULL(filename, NULL);
     1734    PS_ASSERT_METADATA_NON_NULL(md, NULL);
     1735    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    17361736    FILE *file;
    17371737    if ( !(file = fopen(filename, "w")) ) {
     
    17601760                           psMetadata *md)
    17611761{
    1762     PS_ASSERT_PTR_NON_NULL(md, false);
     1762    PS_ASSERT_METADATA_NON_NULL(md, false);
    17631763    PS_ASSERT_PTR_NON_NULL(stream, false);
    17641764    if (fprintf(stream, "\n") <= 0) {
  • trunk/psLib/src/types/psMetadataItemParse.c

    r11686 r12289  
    4141                              )
    4242{
    43     PS_ASSERT_PTR_NON_NULL(item, false);
     43    PS_ASSERT_METADATA_ITEM_NON_NULL(item, false);
    4444
    4545    switch (item->type) {
     
    7171                            )
    7272{
    73     PS_ASSERT_PTR_NON_NULL(item, NAN);
     73    PS_ASSERT_METADATA_ITEM_NON_NULL(item, NAN);
    7474
    7575    switch (item->type) {
     
    9494                            )
    9595{
    96     PS_ASSERT_PTR_NON_NULL(item, NAN);
     96    PS_ASSERT_METADATA_ITEM_NON_NULL(item, NAN);
    9797
    9898    switch (item->type) {
     
    117117                          )
    118118{
    119     PS_ASSERT_PTR_NON_NULL(item, 0);
     119    PS_ASSERT_METADATA_ITEM_NON_NULL(item, 0);
    120120
    121121    switch (item->type) {
     
    140140                            )
    141141{
    142     PS_ASSERT_PTR_NON_NULL(item, 0);
     142    PS_ASSERT_METADATA_ITEM_NON_NULL(item, 0);
    143143
    144144    switch (item->type) {
     
    163163                            )
    164164{
    165     PS_ASSERT_PTR_NON_NULL(item, 0);
     165    PS_ASSERT_METADATA_ITEM_NON_NULL(item, 0);
    166166
    167167    switch (item->type) {
     
    186186                          )
    187187{
    188     PS_ASSERT_PTR_NON_NULL(item, 0);
     188    PS_ASSERT_METADATA_ITEM_NON_NULL(item, 0);
    189189
    190190    switch (item->type) {
     
    209209                            )
    210210{
    211     PS_ASSERT_PTR_NON_NULL(item, 0);
     211    PS_ASSERT_METADATA_ITEM_NON_NULL(item, 0);
    212212
    213213    switch (item->type) {
     
    232232                            )
    233233{
    234     PS_ASSERT_PTR_NON_NULL(item, 0);
     234    PS_ASSERT_METADATA_ITEM_NON_NULL(item, 0);
    235235
    236236    switch (item->type) {
     
    261261                                  )
    262262{
    263     PS_ASSERT_PTR_NON_NULL(item, NULL);
     263    PS_ASSERT_METADATA_ITEM_NON_NULL(item, NULL);
    264264
    265265    switch (item->type) {
  • trunk/psLib/src/types/psPixels.c

    r11707 r12289  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-02-08 21:29:50 $
     9 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-03-07 02:50:15 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psError.h"
    2626
     27#define PIXELS_DEFAULT_ADD 10           // Default number to add, if not specified
    2728
    2829typedef int(*qsortCompareFcn)(const void *, const void *);
     
    3031static void pixelsFree(psPixels* pixels)
    3132{
     33    assert(pixels);
    3234    psFree(pixels->data);
    3335}
     
    118120{
    119121    if (growth < 1) {
    120         growth = 10;
     122        growth = PIXELS_DEFAULT_ADD;
    121123    }
    122124
     
    141143                         const psPixels* pixels)
    142144{
    143     if (pixels == NULL) {
    144         psError(PS_ERR_BAD_PARAMETER_NULL,true,_("Input psPixels can not be NULL."));
    145         psFree(out);
    146         return NULL;
    147     }
     145    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
    148146
    149147    out = p_psPixelsRealloc(file, lineno, func, out, pixels->n);
    150 
    151148    memcpy(out->data,pixels->data, pixels->n*sizeof(psPixelCoord));
    152149    out->n = pixels->n;
     
    160157                        psMaskType maskVal)
    161158{
    162     // check that the input pixel vector is valid
    163     if (pixels == NULL) {
    164         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    165                 _("Input psPixels can not be NULL."));
    166         psFree(out);
    167         return NULL;
    168     }
    169     psPixelCoord* data = pixels->data;
    170     if (data == NULL) {
    171         psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    172                 _("Input psPixels contains no data."));
    173         psFree(out);
    174         return NULL;
    175     }
     159    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
    176160
    177161    float x0 = region.x0;
     
    224208    psMaskType** outData = out->data.PS_TYPE_MASK_DATA;
    225209    for (int p = 0; p < length; p++) {
    226         float x = data[p].x;
    227         float y = data[p].y;
     210        float x = pixels->data[p].x;
     211        float y = pixels->data[p].y;
    228212        // pixel in region?
    229213        if (x >= x0 && x <= x1 && y >= y0 && y <= y1) {
     
    239223                           psMaskType maskVal)
    240224{
    241     if (mask == NULL) {
    242         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    243                 _("Specified mask can not be NULL."));
    244         psFree(out);
    245         return NULL;
    246     }
    247     if (mask->type.type != PS_TYPE_MASK) {
    248         char* typeStr;
    249         PS_TYPE_NAME(typeStr,mask->type.type);
    250         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    251                 _("Specified mask's type, %s, is invalid.  Should be PS_TYPE_MASK."),
    252                 typeStr);
    253         psFree(out);
    254         return NULL;
    255     }
     225    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
     226    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     227
    256228    int numRows = mask->numRows;
    257229    int numCols = mask->numCols;
     
    302274                              const psPixels *pixels)
    303275{
    304     if (pixels == NULL) {
    305         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    306                 _("Input psPixels can not be NULL."));
    307         psFree(out);
    308         return NULL;
    309     }
     276    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
    310277
    311278    long pixelsN = pixels->n;
     
    343310}
    344311
    345 bool p_psPixelsPrint (FILE *fd,
    346                       psPixels* pixels,
    347                       const char *name)
    348 {
     312bool p_psPixelsPrint(FILE *fd,
     313                     psPixels* pixels,
     314                     const char *name)
     315{
     316    PS_ASSERT_PIXELS_NON_NULL(pixels, false);
     317
    349318    if (fd == NULL) {
    350319        fd = stdout;
     
    361330    }
    362331
    363     if (pixels == NULL) {
    364         fprintf(fd,"NULL\n\n");
    365         return true;
    366     }
    367 
    368332    long n = pixels->n;
    369333    psPixelCoord* data = pixels->data;
     
    385349                 psPixelCoord value)
    386350{
    387     if (pixels == NULL) {
    388         psError(PS_ERR_BAD_PARAMETER_NULL, true, _("Input psPixels can not be NULL."));
     351    PS_ASSERT_PIXELS_NON_NULL(pixels, false);
     352
     353    if (position < 0) {
     354        position += pixels->n;
     355    }
     356    if (position < 0 || position > pixels->n) {
     357        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position: %ld\n", position);
    389358        return false;
    390     }
    391     if (position > pixels->n) {
    392         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    393         return false;
    394     }
    395     if(position < 0) {
    396         position += pixels->n;
    397     }
    398     if(position < 0) {
    399         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
    400         return false;
    401     }
    402     if (position == pixels->n) {
    403         if (position >= pixels->nalloc) {
    404             psError(PS_ERR_BAD_PARAMETER_NULL, true,
    405                     "Specified position, %ld, is greater than n+1 of the pixels, %ld.",
    406                     position, pixels->nalloc);
    407             return false;
    408         }
    409         pixels->n++;
    410359    }
    411360    pixels->data[position].x = value.x;
     
    421370    if (pixels == NULL) {
    422371        psError(PS_ERR_BAD_PARAMETER_NULL, true, _("Input psPixels can not be NULL."));
    423         out.x = NAN; //XXX: should be NAN when changed to float
    424         out.y = NAN; //XXX: should be NAN when changed to float
     372        out.x = NAN;
     373        out.y = NAN;
    425374        return out;
     375    }
     376    if (position < 0) {
     377        position += pixels->n;
    426378    }
    427379    if (position >= pixels->n) {
    428380        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    429         out.x = NAN; //XXX: should be NAN when changed to float
    430         out.y = NAN; //XXX: should be NAN when changed to float
     381        out.x = NAN;
     382        out.y = NAN;
    431383        return out;
    432     }
    433     if (position < 0) {
    434         position += pixels->n;
    435384    }
    436385    if (position < 0) {
    437386        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
    438         out.x = NAN; //XXX: should be NAN when changed to float
    439         out.y = NAN; //XXX: should be NAN when changed to float
     387        out.x = NAN;
     388        out.y = NAN;
    440389        return out;
    441390    }
     
    447396long psPixelsLength(const psPixels *pixels)
    448397{
    449     if ( !psMemCheckPixels((psPixels*)pixels) ) {
    450         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    451                 "Error:  Specified pixels is not a valid psPixels \n");
    452         return -1;
    453     }
    454     return (pixels->n);
    455 }
    456 
     398    PS_ASSERT_PIXELS_NON_NULL(pixels, -1);
     399    return pixels->n;
     400}
     401
  • trunk/psLib/src/types/psPixels.h

    r11707 r12289  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-02-08 21:29:50 $
     8 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-03-07 02:50:15 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4949psPixels;
    5050
     51#define PS_ASSERT_PIXELS_NON_NULL(NAME, RVAL) \
     52if (!(NAME) || !(NAME)->data || (NAME)->n < 0 || (NAME)->nalloc < 0) { \
     53    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     54            "Error: Pixels %s or one of its components is NULL.", \
     55            #NAME); \
     56    return RVAL; \
     57}
     58
    5159#define P_PSPIXELS_SET_NALLOC(pix,n) *(long*)&pix->nalloc = n
    5260
Note: See TracChangeset for help on using the changeset viewer.