IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1920


Ignore:
Timestamp:
Sep 28, 2004, 1:26:49 PM (22 years ago)
Author:
desonia
Message:

changed function prototypes to match changes in the SDRS.

Location:
trunk/psLib
Files:
20 edited

Legend:

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

    r1807 r1920  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-14 20:01:52 $
     11 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-28 23:26:48 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121/******************************************************************************/
    2222#include<stdlib.h>                         // for qsort, etc.
     23#include<string.h>
    2324
    2425#include "psMemory.h"
     
    5859}
    5960
    60 psArray* psArrayRealloc(unsigned int nalloc, psArray* restrict in)
     61psArray* psArrayRealloc(psArray* restrict in, unsigned int nalloc)
    6162{
    6263    if (in == NULL) {
     
    8889}
    8990
     91bool psArrayRemove(psArray* psArr,
     92                   psPTR data)
     93{
     94    bool success = false;
     95
     96    if (psArr == NULL) {
     97        return success;
     98    }
     99
     100    int n = psArr->n;
     101    psPTR* psArrData = psArr->data;
     102    for (int i = n-1; i<0; i--) {
     103        if (psArrData[i] == data) {
     104            memmove(psArrData[i],psArrData[i+1],(n-i-1)*sizeof(psPTR));
     105            n--;
     106            success = true;
     107        }
     108    }
     109    psArr->n = n; // reset the array size to indicate the removed item(s)
     110
     111    return success;
     112}
     113
    90114void psArrayElementFree(psArray* restrict psArr)
    91115{
  • trunk/psLib/src/collections/psArray.h

    r1471 r1920  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-08-11 19:47:31 $
     14 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-28 23:26:48 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#ifndef PS_ARRAY_H
    2121#define PS_ARRAY_H
     22
     23#include<stdbool.h>
    2224
    2325#include "psType.h"
     
    6769 */
    6870psArray* psArrayRealloc(
    69     unsigned int nalloc,               ///< Total number of elements to make available.
    70     psArray* restrict psArr            ///< array to reallocate.
     71    psArray* restrict psArr,           ///< array to reallocate.
     72    unsigned int nalloc                ///< Total number of elements to make available.
     73);
     74
     75/** Remove an element from the array
     76 *
     77 *  Finds and removes the specified data pointer from the list. 
     78 *
     79 * @return bool:  TRUE if the specified data pointer was found and removed,
     80 *                otherwise FALSE.
     81 *
     82 */
     83bool psArrayRemove(
     84    psArray* psArr,                    ///< array to operate on
     85    psPTR data                         ///< the data pointer to remove from psArray
    7186);
    7287
  • trunk/psLib/src/collections/psVector.c

    r1897 r1920  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-09-25 02:06:12 $
     12*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-09-28 23:26:48 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6464}
    6565
    66 psVector* psVectorRealloc(unsigned int nalloc, psVector* restrict in)
     66psVector* psVectorRealloc(psVector* restrict in, unsigned int nalloc)
    6767{
    6868    int elementSize = 0;
  • trunk/psLib/src/collections/psVector.h

    r1897 r1920  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-09-25 02:06:12 $
     14 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-28 23:26:48 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383 */
    8484psVector* psVectorRealloc(
    85     unsigned int nalloc,               ///< Total number of elements to make available.
    86     psVector* restrict psVec           ///< Vector to reallocate.
     85    psVector* restrict psVec,          ///< Vector to reallocate.
     86    unsigned int nalloc                ///< Total number of elements to make available.
    8787);
    8888
  • trunk/psLib/src/image/psImage.c

    r1897 r1920  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-25 02:06:12 $
     12 *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-28 23:26:48 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6868    *(psElemType* ) & image->type.type = type;
    6969    image->parent = NULL;
    70     image->nChildren = 0;
    7170    image->children = NULL;
    7271
     
    8180
    8281    if (image->type.type == PS_TYPE_PTR) {
    83         // 2-D array of pointers -- must
    84         // dereference
     82        // 2-D array of pointers -- must dereference elements
    8583        unsigned int oldNumRows = image->numRows;
    8684        unsigned int oldNumCols = image->numCols;
     
    9593    }
    9694
     95    if (image->parent != NULL) {
     96        psArrayRemove(image->parent->children,image);
     97        image->parent = NULL;
     98    }
     99
    97100    psImageFreeChildren(image);
    98101
    99102    psFree(image->rawDataBuffer);
    100103    psFree(image->data.V);
    101     image->data.V = NULL;
    102104}
    103105
     
    164166int psImageFreeChildren(psImage* image)
    165167{
    166     int i = 0;
    167     int nChildren = 0;
    168     psImage* *children = NULL;
    169168    int numFreed = 0;
    170169
     
    173172    }
    174173
    175     nChildren = image->nChildren;
    176     children = image->children;
    177 
    178     for (i = 0; i < nChildren; i++) {
    179         if (children[i] != NULL) {
    180             numFreed++;
    181             psFree(children[i]);
     174    if (image->children != NULL) {
     175        psImage** children = (psImage**)image->children->data;
     176        numFreed = image->children->n;
     177
     178        // orphan the children first
     179        // (so psFree doesn't try to modify the parent's children array while I'm using it)
     180        for (int i=0;i<numFreed;i++) {
     181            children[i]->parent = NULL;
    182182        }
    183     }
    184     psFree(children);
    185 
    186     image->nChildren = 0;
    187     image->children = NULL;
     183
     184        psFree(image->children);
     185        image->children = NULL;
     186    }
    188187
    189188    return numFreed;
  • trunk/psLib/src/image/psImage.h

    r1897 r1920  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-25 02:06:12 $
     13 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-28 23:26:48 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222
    2323#include "psType.h"
     24#include "psArray.h"
    2425
    2526/// @addtogroup Image
     
    6768    } data;                            ///< Union for data types.
    6869    const struct psImage* parent;      ///< Parent, if a subimage.
    69     int nChildren;                     ///< Number of subimages.
    70     struct psImage* *children;         ///< Children of this region.
     70    psArray* children;                 ///< Children of this region.
    7171
    7272    void* rawDataBuffer;
  • trunk/psLib/src/image/psImageExtraction.c

    r1918 r1920  
    1 
    21/** @file  psImageExtraction.c
    3 *
    4 *  @brief Contains basic image extraction operations, as specified in the
    5 *         PSLIB SDRS sections "Image Pixel Extractions" and "Image Structure
    6 *         Manipulation".
    7 *
    8 *  @ingroup Image
    9 *
    10 *  @author Robert DeSonia, MHPCC
    11 *
    12 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-09-28 02:27:58 $
    14 *
    15 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    16 *
    17 */
     2 *
     3 *  @brief Contains basic image extraction operations, as specified in the
     4 *         PSLIB SDRS sections "Image Pixel Extractions" and "Image Structure
     5 *         Manipulation".
     6 *
     7 *  @ingroup Image
     8 *
     9 *  @author Robert DeSonia, MHPCC
     10 *
     11 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-28 23:26:48 $
     13 *
     14 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     15 *
     16 */
    1817
    1918#include <string.h>
     
    2524#include "psImageErrors.h"
    2625
    27 psImage* psImageSubset(psImage* image,
    28                        int col0,
    29                        int row0,
    30                        int col1,
    31                        int row1)
     26
     27psImage* imageSubset(psImage* out,
     28                     psImage* image,
     29                     int col0,
     30                     int row0,
     31                     int col1,
     32                     int row1)
    3233{
    33     psImage* out;
    3434    unsigned int elementSize;          // size of image element in bytes
    3535    unsigned int inputColOffset;       // offset in bytes to first subset pixel in input row
     
    7070    }
    7171    int numRows = row1-row0;
    72     int numCols = col1-row0;
     72    int numCols = col1-col0;
    7373
    7474    elementSize = PSELEMTYPE_SIZEOF(image->type.type);
    7575
    76     out = psAlloc(sizeof(psImage));
     76    if (image->parent != NULL) { // if this is a child, we need to start working with parent.
     77        col0 += image->col0;
     78        col1 += image->col0;
     79        row0 += image->row0;
     80        row1 += image->row0;
     81        image = (psImage*)image->parent;
     82    }
     83
     84    // increment the raw data buffer before freeing anything in the 'out'
     85    void* rawData = psMemIncrRefCounter(image->rawDataBuffer);
     86
     87    if (out != NULL) {
     88        // if a child, need to orphan (disassociate from parent) first
     89        if (out->parent != NULL) {
     90            psArrayRemove(out->parent->children,out); // remove from parent's knowledge
     91            out->parent = NULL; // break link to parent
     92        }
     93
     94        psFree(out->rawDataBuffer); // free the previous data reference
     95    } else {
     96        out = psAlloc(sizeof(psImage));
     97        out->data.V = NULL;
     98    }
     99
     100    out->data.V = psRealloc(out->data.V,sizeof(void*)*numRows); // resize row pointer array
    77101    *(psType*)&out->type = image->type;
    78102    *(unsigned int*)&out->numCols = numCols;
     
    81105    *(int*)&out->col0 = col0;
    82106    out->parent = image;
    83     out->nChildren = 0;
    84107    out->children = NULL;
    85     out->rawDataBuffer = psMemIncrRefCounter(image->rawDataBuffer);
    86     out->data.V = psAlloc(sizeof(void*)*numRows);
     108    out->rawDataBuffer = rawData;
    87109
    88110    // set the new psImage's deallocator to the same as the input image
     
    94116    }
    95117
    96     // add output image as a child of the input
    97     // image.
    98     image->nChildren++;
    99     image->children = (psImage**) psRealloc(image->children, image->nChildren * sizeof(psImage* ));
    100     image->children[image->nChildren - 1] = out;
     118    // add output image as a child of the input image.
     119    int n = 0;
     120    psArray* children = image->children;
     121    if (children == NULL) {
     122        children = psArrayAlloc(16); // start with a reasonable size for growth
     123    } else if (children->nalloc == children->n) { // full?
     124        n = children->n;
     125        children = psArrayRealloc(children,n*2); // double the array size
     126    } else {
     127        n = children->n;
     128    }
     129    children->data[n] = out;
     130    children->n = n+1;
     131    image->children = children; // push back any change (esp. if children==NULL before)
    101132
    102133    return (out);
     134}
     135
     136psImage* psImageSubset(psImage* image,
     137                       int col0,
     138                       int row0,
     139                       int col1,
     140                       int row1)
     141{
     142    return imageSubset(NULL,image,col0,row0,col1,row1);
    103143}
    104144
     
    126166        return NULL;
    127167    }
    128     return psImageSubset(image,x1,y1,x2,y2);
     168    return imageSubset(NULL,image,x1,y1,x2,y2);
    129169}
    130170
    131 psImage* psImageTrim(psImage* image, int x0, int x1, int y0, int y1)
     171psImage* psImageTrim(psImage* image, int x0, int y0, int x1, int y1)
    132172{
    133173    if (image == NULL || image->data.V == NULL) {
     
    139179
    140180    if (image->parent != NULL) {
    141         psErrorMsg(PS_ERRORNAME_DOMAIN "psImageTrim",
    142                    PS_ERR_BAD_PARAMETER_NULL, true,
    143                    PS_ERRORTEXT_psImage_NOT_PARENT);
    144         return NULL;
     181        return imageSubset(image,
     182                           (psImage*)image->parent,
     183                           x0+image->col0,
     184                           y0+image->row0,
     185                           x1+image->col0,
     186                           y1+image->row0);
    145187    }
    146188
     
    904946                    int n = buffer[r]->n;
    905947                    if (n == buffer[r]->nalloc) { // in case buffers already full, expand
    906                         buffer[r] = psVectorRealloc(n*2, buffer[r]);
     948                        buffer[r] = psVectorRealloc(buffer[r], n*2);
    907949                        if (bufferMask[r] != NULL) {
    908                             bufferMask[r] = psVectorRealloc(n*2, bufferMask[r]);
     950                            bufferMask[r] = psVectorRealloc(bufferMask[r], n*2);
    909951                        }
    910952                    }
  • trunk/psLib/src/image/psImageExtraction.h

    r1918 r1920  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-09-28 02:27:58 $
     12*  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-09-28 23:26:48 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7676 *
    7777 *  Trim the specified image in-place, which involves shuffling the pixels
    78  *  around in memory.  The pixels in the region [x0:x1,y0:y1] (inclusive)
    79  *  shall consist the output image.
    80  *
    81  *  N.b., An image that has a parent image will be orphaned from the parent
    82  *  upon trimming.  Any children of the trimmed image will also be obliterated,
     78 *  around in memory.  The pixels in the region [col0:col1,row0:row1] shall consist
     79 *  the output image.  The column col1 and row row1 are NOT included in the range.
     80 *  In the event that x1 or y1 are non-positive, they shall be interpreted as
     81 *  being relative to the size of the parent image in that dimension.
     82 *
     83 *  If the entire specified subimage is not contained within the parent
     84 *  image, an error results and the return value will be NULL.
     85 *
     86 *  N.B. If the input psImage is a child of another psImage, no pixel data
     87 *  will be trimmed, rather it equivalent to calling psImageSubset.  If the input
     88 *  psImage is, however, a parent psImage, any children will be obliterated,
    8389 *  i.e., freed from memory.
    8490 *
     
    8793psImage* psImageTrim(
    8894    psImage* image,                    ///< image to trim
    89     int x0,                            ///< column of trim region's left boundary
    90     int x1,                            ///< column of trim region's right boundary
    91     int y0,                            ///< row of trim region's lower boundary
    92     int y1                             ///< row of trim region's upper boundary
     95    int col0,                          ///< column of trim region's left boundary
     96    int row0,                          ///< row of trim region's lower boundary
     97    int col1,                          ///< column of trim region's right boundary
     98    int row1                           ///< row of trim region's upper boundary
    9399);
    94100
  • trunk/psLib/src/mathtypes/psImage.c

    r1897 r1920  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-25 02:06:12 $
     12 *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-28 23:26:48 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6868    *(psElemType* ) & image->type.type = type;
    6969    image->parent = NULL;
    70     image->nChildren = 0;
    7170    image->children = NULL;
    7271
     
    8180
    8281    if (image->type.type == PS_TYPE_PTR) {
    83         // 2-D array of pointers -- must
    84         // dereference
     82        // 2-D array of pointers -- must dereference elements
    8583        unsigned int oldNumRows = image->numRows;
    8684        unsigned int oldNumCols = image->numCols;
     
    9593    }
    9694
     95    if (image->parent != NULL) {
     96        psArrayRemove(image->parent->children,image);
     97        image->parent = NULL;
     98    }
     99
    97100    psImageFreeChildren(image);
    98101
    99102    psFree(image->rawDataBuffer);
    100103    psFree(image->data.V);
    101     image->data.V = NULL;
    102104}
    103105
     
    164166int psImageFreeChildren(psImage* image)
    165167{
    166     int i = 0;
    167     int nChildren = 0;
    168     psImage* *children = NULL;
    169168    int numFreed = 0;
    170169
     
    173172    }
    174173
    175     nChildren = image->nChildren;
    176     children = image->children;
    177 
    178     for (i = 0; i < nChildren; i++) {
    179         if (children[i] != NULL) {
    180             numFreed++;
    181             psFree(children[i]);
     174    if (image->children != NULL) {
     175        psImage** children = (psImage**)image->children->data;
     176        numFreed = image->children->n;
     177
     178        // orphan the children first
     179        // (so psFree doesn't try to modify the parent's children array while I'm using it)
     180        for (int i=0;i<numFreed;i++) {
     181            children[i]->parent = NULL;
    182182        }
    183     }
    184     psFree(children);
    185 
    186     image->nChildren = 0;
    187     image->children = NULL;
     183
     184        psFree(image->children);
     185        image->children = NULL;
     186    }
    188187
    189188    return numFreed;
  • trunk/psLib/src/mathtypes/psImage.h

    r1897 r1920  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-25 02:06:12 $
     13 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-28 23:26:48 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222
    2323#include "psType.h"
     24#include "psArray.h"
    2425
    2526/// @addtogroup Image
     
    6768    } data;                            ///< Union for data types.
    6869    const struct psImage* parent;      ///< Parent, if a subimage.
    69     int nChildren;                     ///< Number of subimages.
    70     struct psImage* *children;         ///< Children of this region.
     70    psArray* children;                 ///< Children of this region.
    7171
    7272    void* rawDataBuffer;
  • trunk/psLib/src/mathtypes/psVector.c

    r1897 r1920  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-09-25 02:06:12 $
     12*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-09-28 23:26:48 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6464}
    6565
    66 psVector* psVectorRealloc(unsigned int nalloc, psVector* restrict in)
     66psVector* psVectorRealloc(psVector* restrict in, unsigned int nalloc)
    6767{
    6868    int elementSize = 0;
  • trunk/psLib/src/mathtypes/psVector.h

    r1897 r1920  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-09-25 02:06:12 $
     14 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-28 23:26:48 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383 */
    8484psVector* psVectorRealloc(
    85     unsigned int nalloc,               ///< Total number of elements to make available.
    86     psVector* restrict psVec           ///< Vector to reallocate.
     85    psVector* restrict psVec,          ///< Vector to reallocate.
     86    unsigned int nalloc                ///< Total number of elements to make available.
    8787);
    8888
  • trunk/psLib/src/types/psArray.c

    r1807 r1920  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-14 20:01:52 $
     11 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-28 23:26:48 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121/******************************************************************************/
    2222#include<stdlib.h>                         // for qsort, etc.
     23#include<string.h>
    2324
    2425#include "psMemory.h"
     
    5859}
    5960
    60 psArray* psArrayRealloc(unsigned int nalloc, psArray* restrict in)
     61psArray* psArrayRealloc(psArray* restrict in, unsigned int nalloc)
    6162{
    6263    if (in == NULL) {
     
    8889}
    8990
     91bool psArrayRemove(psArray* psArr,
     92                   psPTR data)
     93{
     94    bool success = false;
     95
     96    if (psArr == NULL) {
     97        return success;
     98    }
     99
     100    int n = psArr->n;
     101    psPTR* psArrData = psArr->data;
     102    for (int i = n-1; i<0; i--) {
     103        if (psArrData[i] == data) {
     104            memmove(psArrData[i],psArrData[i+1],(n-i-1)*sizeof(psPTR));
     105            n--;
     106            success = true;
     107        }
     108    }
     109    psArr->n = n; // reset the array size to indicate the removed item(s)
     110
     111    return success;
     112}
     113
    90114void psArrayElementFree(psArray* restrict psArr)
    91115{
  • trunk/psLib/src/types/psArray.h

    r1471 r1920  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-08-11 19:47:31 $
     14 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-09-28 23:26:48 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#ifndef PS_ARRAY_H
    2121#define PS_ARRAY_H
     22
     23#include<stdbool.h>
    2224
    2325#include "psType.h"
     
    6769 */
    6870psArray* psArrayRealloc(
    69     unsigned int nalloc,               ///< Total number of elements to make available.
    70     psArray* restrict psArr            ///< array to reallocate.
     71    psArray* restrict psArr,           ///< array to reallocate.
     72    unsigned int nalloc                ///< Total number of elements to make available.
     73);
     74
     75/** Remove an element from the array
     76 *
     77 *  Finds and removes the specified data pointer from the list. 
     78 *
     79 * @return bool:  TRUE if the specified data pointer was found and removed,
     80 *                otherwise FALSE.
     81 *
     82 */
     83bool psArrayRemove(
     84    psArray* psArr,                    ///< array to operate on
     85    psPTR data                         ///< the data pointer to remove from psArray
    7186);
    7287
  • trunk/psLib/test/collections/tst_psArray.c

    r1406 r1920  
    1212 *  @author  Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    15  *  @date  $Date: 2004-08-06 22:34:05 $
     14 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     15 *  @date  $Date: 2004-09-28 23:26:49 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383    // Test C - Reallocate void pointer array bigger
    8484    printPositiveTestHeader(stdout,"psArray", "Reallocate void pointer array bigger");
    85     psArr = psArrayRealloc(10, psArr);
     85    psArr = psArrayRealloc(psArr,10);
    8686    printf("Adding more elements to void pointer array...\n");
    8787    for(int i = 5; i < 10; i++) {
     
    117117    // Test D - Reallocate void pointer array smaller
    118118    printPositiveTestHeader(stdout,"psArray","Reallocate void pointer array smaller");
    119     psArr = psArrayRealloc(3, psArr);
     119    psArr = psArrayRealloc(psArr,3);
    120120    for(int i = 0; i < 3; i++) {
    121121        testStruct *ts = (testStruct*)psArr->data[i];
  • trunk/psLib/test/collections/tst_psVector.c

    r1406 r1920  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2004-08-06 22:34:05 $
     16 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2004-09-28 23:26:49 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5151    // Test C - Reallocate S32 vector bigger
    5252    printPositiveTestHeader(stdout,"psVector", "Reallocate S32 vector bigger");
    53     psVec = psVectorRealloc(10, psVec);
     53    psVec = psVectorRealloc(psVec,10);
    5454    printf("Adding more elements to S32 vector...\n");
    5555    for(int i = 5; i < 10; i++) {
     
    6565    // Test D - Reallocate S32 vector smaller
    6666    printPositiveTestHeader(stdout,"psVector","Reallocate S32 vector smaller");
    67     psVec = psVectorRealloc(3, psVec);
     67    psVec = psVectorRealloc(psVec,3);
    6868    printf("Vector size = %d\n", psVec->nalloc);
    6969    for(int i = 0; i < 3; i++) {
     
    104104                            "Null input vector", 0);
    105105    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error message.");
    106     psVectorRealloc(6, NULL);
     106    psVectorRealloc(NULL,6);
    107107    printFooter(stdout, "psVector", "Attempt to realloc a null S32 vector", true);
    108108
  • trunk/psLib/test/image/tst_psImage.c

    r1682 r1920  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-02 21:17:03 $
     8 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-28 23:26:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626
    2727testDescription tests[] = {
    28                               {
    29                                   testImageAlloc,546,"psImageAlloc",0,false
    30                               },
    31                               {
    32                                   testImageAlloc,548,"psImageFree",0,true
    33                               },
    34                               {
    35                                   testImageSubset,547,"psImageSubset",0,false
    36                               },
    37                               {
    38                                   testImageSubset,550,"psImageSubset",0,true
    39                               },
    40                               {
    41                                   testImageCopy,551,"psImageCopy",0,false
    42                               },
    43                               {
    44                                   NULL
    45                               }
     28                              {testImageAlloc,546,"psImageAlloc",0,false},
     29                              {testImageAlloc,548,"psImageFree",0,true},
     30                              {testImageSubset,547,"psImageSubset",0,false},
     31                              {testImageSubset,550,"psImageSubset",0,true},
     32                              {testImageCopy,551,"psImageCopy",0,false},
     33                              {NULL}
    4634                          };
    4735
     
    119107            }
    120108
    121             if (image->nChildren != 0) {
    122                 psError(__func__,"psImageAlloc returned non-zero number of children");
    123                 psFree(image);
    124                 return 6;
    125             }
    126 
    127109            if (image->children != NULL) {
    128                 psError(__func__,"psImageAlloc returned non-NULL children vector");
     110                psError(__func__,"psImageAlloc returned non-NULL children array");
    129111                psFree(image);
    130112                return 7;
     
    259241                }
    260242            }
    261 
    262             // #548: Verify no memory leaks or corruption are detected after a valid psImage structure with no
    263             // children is freed.
    264243            psFree(image);
    265244        }
    266245    }
    267246
    268     // #548: Verify program execution doesn't stop, if the input psImage structure pointer is null.
    269     psFree(NULL);
    270 
    271247    // #548: Verify no memory leaks or corruption are detected after a valid psImage structure with multiple
    272     // children isfreed.
     248    // children is freed.
    273249    image = psImageAlloc(100,100,PS_TYPE_F32);
    274     psImageSubset(image,50,50,0,0);
    275     psImageSubset(image,50,50,20,20);
     250    psImageSubset(image,50,0,70,20);
     251    psImageSubset(image,70,20,90,40);
    276252
    277253    psFree(image);
     
    300276    memcpy(&preSubsetStruct,original,sizeof(psImage));
    301277
    302     subset2 = psImageSubset(original,c/2,r/2,c/4,r/4);
    303 
    304     subset3 = psImageSubset(original,c/2,r/2,0,0);
     278    subset2 = psImageSubset(original,c/4,r/4,c/4+c/2,r/4+r/2);
     279
     280    subset3 = psImageSubset(original,0,0,c/2,r/2);
     281
     282    psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure members nrow and ncol are equal to "
     283             "the input parameter nrow and ncol respectively.");
     284
     285    if (subset2->numCols != c/2 || subset2->numRows != r/2) {
     286        psError(__func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
     287                subset2->numCols, subset2->numRows, c/2,r/2);
     288        return 1;
     289    }
     290
     291    if (subset3->numCols != c/2 || subset3->numRows != r/2) {
     292        psError(__func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
     293                subset3->numCols, subset3->numRows, c/2,r/2);
     294        return 2;
     295    }
    305296
    306297    psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure contains expected values in the "
     
    322313    }
    323314
    324     psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure members nrow and ncol are equal to "
    325              "the input parameter nrow and ncol respectively.");
    326 
    327     if (subset3->numCols != c/2 || subset3->numRows != r/2) {
    328         psError(__func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
    329                 subset3->numCols, subset3->numRows, c/2,r/2);
    330         return 5;
    331     }
    332 
    333315    psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member type is equal to the input "
    334316             "psImage structure member type.");
     
    367349    }
    368350
    369     psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member Nchildren is equal to "
    370              "zero.");
    371 
    372     if (subset2->nChildren != 0 || subset3->nChildren != 0) {
    373         psError(__func__,"psImageSubset didn't set nChildren to zero.");
    374         return 11;
    375     }
    376 
    377351    psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member children is null.");
    378352
     
    386360             "out at parent[Nchildren-1].");
    387361
    388     if (original->nChildren != preSubsetStruct.nChildren+2) {
    389         psError(__func__,"psImageSubset didn't increment nChildren by one per subset.");
     362    if (original->children == NULL || original->children->n != 2) {
     363        psError(__func__,"psImageSubset didn't increment number of children by one per subset.");
    390364        return 12;
    391365    }
    392     if (original->children[0] != subset2 || original->children[1] != subset3) {
     366    if (original->children->data[0] != subset2 || original->children->data[1] != subset3) {
    393367        psError(__func__,"psImageSubset didn't properly store the children pointers.");
    394368        return 13;
     
    400374
    401375    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    402     subset1 = psImageSubset(NULL,c/2,r/2,0,0);
     376    subset1 = psImageSubset(NULL,0,0,c/2,r/2);
    403377    if (subset1 != NULL) {
    404378        psError(__func__,"psImageSubset didn't return NULL when input image was NULL.");
     
    412386    memcpy(&preSubsetStruct,original,sizeof(psImage));
    413387    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    414     subset1 = psImageSubset(original,c/2,0,0,0);
     388    subset1 = psImageSubset(original,0,r/2,c/2,r/2);
    415389    if (subset1 != NULL) {
    416390        psError(__func__,"psImageSubset didn't return NULL when numRows=0.");
     
    418392    }
    419393    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    420     subset1 = psImageSubset(original,0,r/2,0,0);
     394    subset1 = psImageSubset(original,c/2,0,c/2,r/2);
    421395    if (subset1 != NULL) {
    422396        psError(__func__,"psImageSubset didn't return NULL when numCols=0.");
     
    434408
    435409    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    436     subset1 = psImageSubset(original,c/2,r/2,c,0);
     410    subset1 = psImageSubset(original,0,0,c/2,r*2);
    437411    if (subset1 != NULL) {
    438412        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
     
    441415    }
    442416    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    443     subset1 = psImageSubset(original,c/2,r/2,0,r);
     417    subset1 = psImageSubset(original,0,0,c*2,r/2);
    444418    if (subset1 != NULL) {
    445419        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
     
    448422    }
    449423    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    450     subset1 = psImageSubset(original,c/2,r/2,-1,0);
     424    subset1 = psImageSubset(original,-1,0,c/2,r/2);
    451425    if (subset1 != NULL) {
    452426        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
     
    455429    }
    456430    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    457     subset1 = psImageSubset(original,c/2,r/2,0,-1);
     431    subset1 = psImageSubset(original,0,-1,c/2,r/2);
    458432    if (subset1 != NULL) {
    459433        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
     
    468442
    469443    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    470     subset1 = psImageSubset(original,c/2,r/2,c/2,0);
     444    subset1 = psImageSubset(original,0,0,c/2,r+1);
    471445    if (subset1 != NULL) {
    472446        psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via rows).");
     
    474448    }
    475449    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    476     subset1 = psImageSubset(original,c/2,r/2,0,r/2);
     450    subset1 = psImageSubset(original,0,0,c+1,r/2);
    477451    if (subset1 != NULL) {
    478452        psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via cols).");
     
    480454    }
    481455    psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");
    482     subset1 = psImageSubset(original,c/2,r/2,c/2,r/2);
     456    subset1 = psImageSubset(original,0,0,c+1,r+1);
    483457    if (subset1 != NULL) {
    484458        psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via row+cols).");
     
    494468
    495469    // Verify the returned psImage structure member Nchildren is set to zero.
    496     if (original->nChildren != 0) {
    497         psError(__func__,"psImageFreeChildren didn't set nChildren to zero.");
     470    if (original->children != NULL && original->children->n > 0) {
     471        psError(__func__,"psImageFreeChildren didn't set number of children to zero.");
    498472        return 25;
    499     }
    500 
    501     // Verify the returned psImage structure member children pointer is set to null.
    502     if (original->children != NULL) {
    503         psError(__func__,"psImageFreeChildren didn't set children ptr to NULL.");
    504         return 26;
    505473    }
    506474
  • trunk/psLib/test/image/verified/tst_psImage.stderr

    r1840 r1920  
    9595
    9696<DATE><TIME>|<HOST>|I|testImageSubset
     97    Verify the returned psImage structure members nrow and ncol are equal to the input parameter nrow and ncol respectively.
     98<DATE><TIME>|<HOST>|I|testImageSubset
    9799    Verify the returned psImage structure contains expected values in the row member, if the input psImage structure image contains known values.
    98 <DATE><TIME>|<HOST>|I|testImageSubset
    99     Verify the returned psImage structure members nrow and ncol are equal to the input parameter nrow and ncol respectively.
    100100<DATE><TIME>|<HOST>|I|testImageSubset
    101101    Verify the returned psImage structure member type is equal to the input psImage structure member type.
     
    104104<DATE><TIME>|<HOST>|I|testImageSubset
    105105    Verify the returned psImage structure member parent is equal to the input psImage structure pointer image.
    106 <DATE><TIME>|<HOST>|I|testImageSubset
    107     Verify the returned psImage structure member Nchildren is equal to zero.
    108106<DATE><TIME>|<HOST>|I|testImageSubset
    109107    Verify the returned psImage structure member children is null.
     
    121119    An error should follow...
    122120<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    123     Specified number of rows (64) or columns (0) is invalid.
     121    Specified subset range, [0:<LINENO>,128:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    124122<DATE><TIME>|<HOST>|I|testImageSubset
    125123    An error should follow...
    126124<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    127     Specified number of rows (0) or columns (128) is invalid.
     125    Specified subset range, [64:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    128126<DATE><TIME>|<HOST>|I|testImageSubset
    129127    Verify the returned psImage structure pointer is null and program execution doesn't stop, if the input parameters row0 and col0 are not within the range of values of psImage structure image.
     
    131129    An error should follow...
    132130<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    133     Specified subset range, [128:<LINENO>,0:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     131    Specified subset range, [0:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    134132<DATE><TIME>|<HOST>|I|testImageSubset
    135133    An error should follow...
    136134<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    137     Specified subset range, [0:<LINENO>,256:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     135    Specified subset range, [0:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    138136<DATE><TIME>|<HOST>|I|testImageSubset
    139137    An error should follow...
    140138<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    141     Specified subset range, [-1:<LINENO>,0:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     139    Specified subset range, [-1:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    142140<DATE><TIME>|<HOST>|I|testImageSubset
    143141    An error should follow...
    144142<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    145     Specified subset range, [0:<LINENO>,-1:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     143    Specified subset range, [0:<LINENO>,-1:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    146144<DATE><TIME>|<HOST>|I|testImageSubset
    147145    Verify the returned psImage structure pointer is null and program execution doesn't stop if the input parameters nrow, ncol, row0 and col0 specify a range of data not within the input psImage structure image.  Also verify the input psImage structure is not modified.
     
    149147    An error should follow...
    150148<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    151     Specified subset range, [64:<LINENO>,0:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     149    Specified subset range, [0:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    152150<DATE><TIME>|<HOST>|I|testImageSubset
    153151    An error should follow...
    154152<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    155     Specified subset range, [0:<LINENO>,128:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     153    Specified subset range, [0:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    156154<DATE><TIME>|<HOST>|I|testImageSubset
    157155    An error should follow...
    158156<DATE><TIME>|<HOST>|E|psLib.image.psImageSubset
    159     Specified subset range, [64:<LINENO>,128:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     157    Specified subset range, [0:<LINENO>,0:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    160158<DATE><TIME>|<HOST>|I|testImageSubset
    161159    psImageFreeChildren shall deallocate any children images of a psImage structure
  • trunk/psLib/test/image/verified/tst_psImageExtraction.stderr

    r1840 r1920  
    2424    Following should be an error.
    2525<DATE><TIME>|<HOST>|E|psLib.image.psImageSlice
    26     Specified subset range, [2001:<LINENO>,2002:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     26    Specified subset range, [2001:<LINENO>,2002:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    2727<DATE><TIME>|<HOST>|I|testImageSlice
    2828    Following should be an error.
    2929<DATE><TIME>|<HOST>|E|psLib.image.psImageSlice
    30     Specified subset range, [200:<LINENO>,201:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     30    Specified subset range, [200:<LINENO>,201:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    3131<DATE><TIME>|<HOST>|I|testImageSlice
    3232    Following should be an error.
    3333<DATE><TIME>|<HOST>|E|psLib.image.psImageSlice
    34     Specified subset range, [200:<LINENO>,2200:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     34    Specified subset range, [200:<LINENO>,2200:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    3535<DATE><TIME>|<HOST>|I|testImageSlice
    3636    Following should be an error.
    3737<DATE><TIME>|<HOST>|E|psLib.image.psImageSlice
    38     Specified subset range, [200:<LINENO>,201:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     38    Specified subset range, [200:<LINENO>,201:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    3939<DATE><TIME>|<HOST>|I|testImageSlice
    4040    Following should be an error.
  • trunk/psLib/test/image/verified/tst_psImageManip.stderr

    r1915 r1920  
    125125    Following should error as overlay isn't within image boundaries
    126126<DATE><TIME>|<HOST>|E|psLib.image.psImageOverlaySection
    127     Specified subset range, [32:<LINENO>,64:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     127    Specified subset range, [32:<LINENO>,64:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    128128<DATE><TIME>|<HOST>|I|testImageOverlay
    129129    Following should error as overlay is NULL
Note: See TracChangeset for help on using the changeset viewer.