Changeset 1920
- Timestamp:
- Sep 28, 2004, 1:26:49 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 20 edited
-
src/collections/psArray.c (modified) (4 diffs)
-
src/collections/psArray.h (modified) (3 diffs)
-
src/collections/psVector.c (modified) (2 diffs)
-
src/collections/psVector.h (modified) (2 diffs)
-
src/image/psImage.c (modified) (6 diffs)
-
src/image/psImage.h (modified) (3 diffs)
-
src/image/psImageExtraction.c (modified) (8 diffs)
-
src/image/psImageExtraction.h (modified) (3 diffs)
-
src/mathtypes/psImage.c (modified) (6 diffs)
-
src/mathtypes/psImage.h (modified) (3 diffs)
-
src/mathtypes/psVector.c (modified) (2 diffs)
-
src/mathtypes/psVector.h (modified) (2 diffs)
-
src/types/psArray.c (modified) (4 diffs)
-
src/types/psArray.h (modified) (3 diffs)
-
test/collections/tst_psArray.c (modified) (3 diffs)
-
test/collections/tst_psVector.c (modified) (4 diffs)
-
test/image/tst_psImage.c (modified) (19 diffs)
-
test/image/verified/tst_psImage.stderr (modified) (5 diffs)
-
test/image/verified/tst_psImageExtraction.stderr (modified) (1 diff)
-
test/image/verified/tst_psImageManip.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psArray.c
r1807 r1920 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $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 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 /******************************************************************************/ 22 22 #include<stdlib.h> // for qsort, etc. 23 #include<string.h> 23 24 24 25 #include "psMemory.h" … … 58 59 } 59 60 60 psArray* psArrayRealloc( unsigned int nalloc, psArray* restrict in)61 psArray* psArrayRealloc(psArray* restrict in, unsigned int nalloc) 61 62 { 62 63 if (in == NULL) { … … 88 89 } 89 90 91 bool 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 90 114 void psArrayElementFree(psArray* restrict psArr) 91 115 { -
trunk/psLib/src/collections/psArray.h
r1471 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-11 19:47:31$14 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:48 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #ifndef PS_ARRAY_H 21 21 #define PS_ARRAY_H 22 23 #include<stdbool.h> 22 24 23 25 #include "psType.h" … … 67 69 */ 68 70 psArray* 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 */ 83 bool psArrayRemove( 84 psArray* psArr, ///< array to operate on 85 psPTR data ///< the data pointer to remove from psArray 71 86 ); 72 87 -
trunk/psLib/src/collections/psVector.c
r1897 r1920 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 02:06:12$12 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-28 23:26:48 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 64 64 } 65 65 66 psVector* psVectorRealloc( unsigned int nalloc, psVector* restrict in)66 psVector* psVectorRealloc(psVector* restrict in, unsigned int nalloc) 67 67 { 68 68 int elementSize = 0; -
trunk/psLib/src/collections/psVector.h
r1897 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-09-2 5 02:06:12$14 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:48 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 83 83 */ 84 84 psVector* 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. 87 87 ); 88 88 -
trunk/psLib/src/image/psImage.c
r1897 r1920 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 02:06:12$12 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-28 23:26:48 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 68 68 *(psElemType* ) & image->type.type = type; 69 69 image->parent = NULL; 70 image->nChildren = 0;71 70 image->children = NULL; 72 71 … … 81 80 82 81 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 85 83 unsigned int oldNumRows = image->numRows; 86 84 unsigned int oldNumCols = image->numCols; … … 95 93 } 96 94 95 if (image->parent != NULL) { 96 psArrayRemove(image->parent->children,image); 97 image->parent = NULL; 98 } 99 97 100 psImageFreeChildren(image); 98 101 99 102 psFree(image->rawDataBuffer); 100 103 psFree(image->data.V); 101 image->data.V = NULL;102 104 } 103 105 … … 164 166 int psImageFreeChildren(psImage* image) 165 167 { 166 int i = 0;167 int nChildren = 0;168 psImage* *children = NULL;169 168 int numFreed = 0; 170 169 … … 173 172 } 174 173 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; 182 182 } 183 } 184 psFree(children); 185 186 image->nChildren = 0; 187 image->children = NULL; 183 184 psFree(image->children); 185 image->children = NULL; 186 } 188 187 189 188 return numFreed; -
trunk/psLib/src/image/psImage.h
r1897 r1920 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-09-2 5 02:06:12$13 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-09-28 23:26:48 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 23 23 #include "psType.h" 24 #include "psArray.h" 24 25 25 26 /// @addtogroup Image … … 67 68 } data; ///< Union for data types. 68 69 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. 71 71 72 72 void* rawDataBuffer; -
trunk/psLib/src/image/psImageExtraction.c
r1918 r1920 1 2 1 /** @file psImageExtraction.c 3 *4 * @brief Contains basic image extraction operations, as specified in the5 * PSLIB SDRS sections "Image Pixel Extractions" and "Image Structure6 * Manipulation".7 *8 * @ingroup Image9 *10 * @author Robert DeSonia, MHPCC11 *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 Hawaii16 *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 */ 18 17 19 18 #include <string.h> … … 25 24 #include "psImageErrors.h" 26 25 27 psImage* psImageSubset(psImage* image, 28 int col0, 29 int row0, 30 int col1, 31 int row1) 26 27 psImage* imageSubset(psImage* out, 28 psImage* image, 29 int col0, 30 int row0, 31 int col1, 32 int row1) 32 33 { 33 psImage* out;34 34 unsigned int elementSize; // size of image element in bytes 35 35 unsigned int inputColOffset; // offset in bytes to first subset pixel in input row … … 70 70 } 71 71 int numRows = row1-row0; 72 int numCols = col1- row0;72 int numCols = col1-col0; 73 73 74 74 elementSize = PSELEMTYPE_SIZEOF(image->type.type); 75 75 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 77 101 *(psType*)&out->type = image->type; 78 102 *(unsigned int*)&out->numCols = numCols; … … 81 105 *(int*)&out->col0 = col0; 82 106 out->parent = image; 83 out->nChildren = 0;84 107 out->children = NULL; 85 out->rawDataBuffer = psMemIncrRefCounter(image->rawDataBuffer); 86 out->data.V = psAlloc(sizeof(void*)*numRows); 108 out->rawDataBuffer = rawData; 87 109 88 110 // set the new psImage's deallocator to the same as the input image … … 94 116 } 95 117 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) 101 132 102 133 return (out); 134 } 135 136 psImage* 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); 103 143 } 104 144 … … 126 166 return NULL; 127 167 } 128 return psImageSubset(image,x1,y1,x2,y2);168 return imageSubset(NULL,image,x1,y1,x2,y2); 129 169 } 130 170 131 psImage* psImageTrim(psImage* image, int x0, int x1, int y0, int y1)171 psImage* psImageTrim(psImage* image, int x0, int y0, int x1, int y1) 132 172 { 133 173 if (image == NULL || image->data.V == NULL) { … … 139 179 140 180 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); 145 187 } 146 188 … … 904 946 int n = buffer[r]->n; 905 947 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); 907 949 if (bufferMask[r] != NULL) { 908 bufferMask[r] = psVectorRealloc( n*2, bufferMask[r]);950 bufferMask[r] = psVectorRealloc(bufferMask[r], n*2); 909 951 } 910 952 } -
trunk/psLib/src/image/psImageExtraction.h
r1918 r1920 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.1 4$ $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 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 76 76 * 77 77 * 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, 83 89 * i.e., freed from memory. 84 90 * … … 87 93 psImage* psImageTrim( 88 94 psImage* image, ///< image to trim 89 int x0,///< column of trim region's left boundary90 int x1, ///< column of trim region's rightboundary91 int y0, ///< row of trim region's lowerboundary92 int y1///< row of trim region's upper boundary95 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 93 99 ); 94 100 -
trunk/psLib/src/mathtypes/psImage.c
r1897 r1920 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 02:06:12$12 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-28 23:26:48 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 68 68 *(psElemType* ) & image->type.type = type; 69 69 image->parent = NULL; 70 image->nChildren = 0;71 70 image->children = NULL; 72 71 … … 81 80 82 81 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 85 83 unsigned int oldNumRows = image->numRows; 86 84 unsigned int oldNumCols = image->numCols; … … 95 93 } 96 94 95 if (image->parent != NULL) { 96 psArrayRemove(image->parent->children,image); 97 image->parent = NULL; 98 } 99 97 100 psImageFreeChildren(image); 98 101 99 102 psFree(image->rawDataBuffer); 100 103 psFree(image->data.V); 101 image->data.V = NULL;102 104 } 103 105 … … 164 166 int psImageFreeChildren(psImage* image) 165 167 { 166 int i = 0;167 int nChildren = 0;168 psImage* *children = NULL;169 168 int numFreed = 0; 170 169 … … 173 172 } 174 173 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; 182 182 } 183 } 184 psFree(children); 185 186 image->nChildren = 0; 187 image->children = NULL; 183 184 psFree(image->children); 185 image->children = NULL; 186 } 188 187 189 188 return numFreed; -
trunk/psLib/src/mathtypes/psImage.h
r1897 r1920 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-09-2 5 02:06:12$13 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-09-28 23:26:48 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 23 23 #include "psType.h" 24 #include "psArray.h" 24 25 25 26 /// @addtogroup Image … … 67 68 } data; ///< Union for data types. 68 69 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. 71 71 72 72 void* rawDataBuffer; -
trunk/psLib/src/mathtypes/psVector.c
r1897 r1920 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 02:06:12$12 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-28 23:26:48 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 64 64 } 65 65 66 psVector* psVectorRealloc( unsigned int nalloc, psVector* restrict in)66 psVector* psVectorRealloc(psVector* restrict in, unsigned int nalloc) 67 67 { 68 68 int elementSize = 0; -
trunk/psLib/src/mathtypes/psVector.h
r1897 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-09-2 5 02:06:12$14 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:48 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 83 83 */ 84 84 psVector* 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. 87 87 ); 88 88 -
trunk/psLib/src/types/psArray.c
r1807 r1920 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $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 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 /******************************************************************************/ 22 22 #include<stdlib.h> // for qsort, etc. 23 #include<string.h> 23 24 24 25 #include "psMemory.h" … … 58 59 } 59 60 60 psArray* psArrayRealloc( unsigned int nalloc, psArray* restrict in)61 psArray* psArrayRealloc(psArray* restrict in, unsigned int nalloc) 61 62 { 62 63 if (in == NULL) { … … 88 89 } 89 90 91 bool 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 90 114 void psArrayElementFree(psArray* restrict psArr) 91 115 { -
trunk/psLib/src/types/psArray.h
r1471 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-11 19:47:31$14 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:48 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #ifndef PS_ARRAY_H 21 21 #define PS_ARRAY_H 22 23 #include<stdbool.h> 22 24 23 25 #include "psType.h" … … 67 69 */ 68 70 psArray* 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 */ 83 bool psArrayRemove( 84 psArray* psArr, ///< array to operate on 85 psPTR data ///< the data pointer to remove from psArray 71 86 ); 72 87 -
trunk/psLib/test/collections/tst_psArray.c
r1406 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-06 22:34:05$14 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:49 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 83 83 // Test C - Reallocate void pointer array bigger 84 84 printPositiveTestHeader(stdout,"psArray", "Reallocate void pointer array bigger"); 85 psArr = psArrayRealloc( 10, psArr);85 psArr = psArrayRealloc(psArr,10); 86 86 printf("Adding more elements to void pointer array...\n"); 87 87 for(int i = 5; i < 10; i++) { … … 117 117 // Test D - Reallocate void pointer array smaller 118 118 printPositiveTestHeader(stdout,"psArray","Reallocate void pointer array smaller"); 119 psArr = psArrayRealloc( 3, psArr);119 psArr = psArrayRealloc(psArr,3); 120 120 for(int i = 0; i < 3; i++) { 121 121 testStruct *ts = (testStruct*)psArr->data[i]; -
trunk/psLib/test/collections/tst_psVector.c
r1406 r1920 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-0 8-06 22:34:05$16 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-09-28 23:26:49 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 51 51 // Test C - Reallocate S32 vector bigger 52 52 printPositiveTestHeader(stdout,"psVector", "Reallocate S32 vector bigger"); 53 psVec = psVectorRealloc( 10, psVec);53 psVec = psVectorRealloc(psVec,10); 54 54 printf("Adding more elements to S32 vector...\n"); 55 55 for(int i = 5; i < 10; i++) { … … 65 65 // Test D - Reallocate S32 vector smaller 66 66 printPositiveTestHeader(stdout,"psVector","Reallocate S32 vector smaller"); 67 psVec = psVectorRealloc( 3, psVec);67 psVec = psVectorRealloc(psVec,3); 68 68 printf("Vector size = %d\n", psVec->nalloc); 69 69 for(int i = 0; i < 3; i++) { … … 104 104 "Null input vector", 0); 105 105 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error message."); 106 psVectorRealloc( 6, NULL);106 psVectorRealloc(NULL,6); 107 107 printFooter(stdout, "psVector", "Attempt to realloc a null S32 vector", true); 108 108 -
trunk/psLib/test/image/tst_psImage.c
r1682 r1920 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 5$ $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 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 27 27 testDescription 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} 46 34 }; 47 35 … … 119 107 } 120 108 121 if (image->nChildren != 0) {122 psError(__func__,"psImageAlloc returned non-zero number of children");123 psFree(image);124 return 6;125 }126 127 109 if (image->children != NULL) { 128 psError(__func__,"psImageAlloc returned non-NULL children vector");110 psError(__func__,"psImageAlloc returned non-NULL children array"); 129 111 psFree(image); 130 112 return 7; … … 259 241 } 260 242 } 261 262 // #548: Verify no memory leaks or corruption are detected after a valid psImage structure with no263 // children is freed.264 243 psFree(image); 265 244 } 266 245 } 267 246 268 // #548: Verify program execution doesn't stop, if the input psImage structure pointer is null.269 psFree(NULL);270 271 247 // #548: Verify no memory leaks or corruption are detected after a valid psImage structure with multiple 272 // children is freed.248 // children is freed. 273 249 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); 276 252 277 253 psFree(image); … … 300 276 memcpy(&preSubsetStruct,original,sizeof(psImage)); 301 277 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 } 305 296 306 297 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure contains expected values in the " … … 322 313 } 323 314 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 333 315 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member type is equal to the input " 334 316 "psImage structure member type."); … … 367 349 } 368 350 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 377 351 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member children is null."); 378 352 … … 386 360 "out at parent[Nchildren-1]."); 387 361 388 if (original-> nChildren != preSubsetStruct.nChildren+2) {389 psError(__func__,"psImageSubset didn't increment n Children 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."); 390 364 return 12; 391 365 } 392 if (original->children [0] != subset2 || original->children[1] != subset3) {366 if (original->children->data[0] != subset2 || original->children->data[1] != subset3) { 393 367 psError(__func__,"psImageSubset didn't properly store the children pointers."); 394 368 return 13; … … 400 374 401 375 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); 403 377 if (subset1 != NULL) { 404 378 psError(__func__,"psImageSubset didn't return NULL when input image was NULL."); … … 412 386 memcpy(&preSubsetStruct,original,sizeof(psImage)); 413 387 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); 415 389 if (subset1 != NULL) { 416 390 psError(__func__,"psImageSubset didn't return NULL when numRows=0."); … … 418 392 } 419 393 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); 421 395 if (subset1 != NULL) { 422 396 psError(__func__,"psImageSubset didn't return NULL when numCols=0."); … … 434 408 435 409 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); 437 411 if (subset1 != NULL) { 438 412 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " … … 441 415 } 442 416 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); 444 418 if (subset1 != NULL) { 445 419 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " … … 448 422 } 449 423 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); 451 425 if (subset1 != NULL) { 452 426 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " … … 455 429 } 456 430 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); 458 432 if (subset1 != NULL) { 459 433 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " … … 468 442 469 443 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); 471 445 if (subset1 != NULL) { 472 446 psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via rows)."); … … 474 448 } 475 449 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); 477 451 if (subset1 != NULL) { 478 452 psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via cols)."); … … 480 454 } 481 455 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); 483 457 if (subset1 != NULL) { 484 458 psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via row+cols)."); … … 494 468 495 469 // Verify the returned psImage structure member Nchildren is set to zero. 496 if (original-> nChildren !=0) {497 psError(__func__,"psImageFreeChildren didn't set n Children to zero.");470 if (original->children != NULL && original->children->n > 0) { 471 psError(__func__,"psImageFreeChildren didn't set number of children to zero."); 498 472 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;505 473 } 506 474 -
trunk/psLib/test/image/verified/tst_psImage.stderr
r1840 r1920 95 95 96 96 <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 97 99 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|testImageSubset99 Verify the returned psImage structure members nrow and ncol are equal to the input parameter nrow and ncol respectively.100 100 <DATE><TIME>|<HOST>|I|testImageSubset 101 101 Verify the returned psImage structure member type is equal to the input psImage structure member type. … … 104 104 <DATE><TIME>|<HOST>|I|testImageSubset 105 105 Verify the returned psImage structure member parent is equal to the input psImage structure pointer image. 106 <DATE><TIME>|<HOST>|I|testImageSubset107 Verify the returned psImage structure member Nchildren is equal to zero.108 106 <DATE><TIME>|<HOST>|I|testImageSubset 109 107 Verify the returned psImage structure member children is null. … … 121 119 An error should follow... 122 120 <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>]. 124 122 <DATE><TIME>|<HOST>|I|testImageSubset 125 123 An error should follow... 126 124 <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>]. 128 126 <DATE><TIME>|<HOST>|I|testImageSubset 129 127 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. … … 131 129 An error should follow... 132 130 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 133 Specified subset range, [ 128:<LINENO>,0:<LINENO>], lies outsidepsImage'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>]. 134 132 <DATE><TIME>|<HOST>|I|testImageSubset 135 133 An error should follow... 136 134 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 137 Specified subset range, [0:<LINENO>, 256:<LINENO>], lies outsidepsImage'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>]. 138 136 <DATE><TIME>|<HOST>|I|testImageSubset 139 137 An error should follow... 140 138 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 141 Specified subset range, [-1:<LINENO>,0:<LINENO>], lies outsidepsImage'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>]. 142 140 <DATE><TIME>|<HOST>|I|testImageSubset 143 141 An error should follow... 144 142 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 145 Specified subset range, [0:<LINENO>,-1:<LINENO>], lies outsidepsImage'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>]. 146 144 <DATE><TIME>|<HOST>|I|testImageSubset 147 145 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. … … 149 147 An error should follow... 150 148 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 151 Specified subset range, [ 64:<LINENO>,0:<LINENO>], lies outsidepsImage'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>]. 152 150 <DATE><TIME>|<HOST>|I|testImageSubset 153 151 An error should follow... 154 152 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 155 Specified subset range, [0:<LINENO>, 128:<LINENO>], lies outsidepsImage'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>]. 156 154 <DATE><TIME>|<HOST>|I|testImageSubset 157 155 An error should follow... 158 156 <DATE><TIME>|<HOST>|E|psLib.image.psImageSubset 159 Specified subset range, [ 64:<LINENO>,128:<LINENO>], lies outsidepsImage'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>]. 160 158 <DATE><TIME>|<HOST>|I|testImageSubset 161 159 psImageFreeChildren shall deallocate any children images of a psImage structure -
trunk/psLib/test/image/verified/tst_psImageExtraction.stderr
r1840 r1920 24 24 Following should be an error. 25 25 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 26 Specified subset range, [2001:<LINENO>,2002:<LINENO>], lies outsidepsImage'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>]. 27 27 <DATE><TIME>|<HOST>|I|testImageSlice 28 28 Following should be an error. 29 29 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 30 Specified subset range, [200:<LINENO>,201:<LINENO>], lies outsidepsImage'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>]. 31 31 <DATE><TIME>|<HOST>|I|testImageSlice 32 32 Following should be an error. 33 33 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 34 Specified subset range, [200:<LINENO>,2200:<LINENO>], lies outsidepsImage'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>]. 35 35 <DATE><TIME>|<HOST>|I|testImageSlice 36 36 Following should be an error. 37 37 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 38 Specified subset range, [200:<LINENO>,201:<LINENO>], lies outsidepsImage'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>]. 39 39 <DATE><TIME>|<HOST>|I|testImageSlice 40 40 Following should be an error. -
trunk/psLib/test/image/verified/tst_psImageManip.stderr
r1915 r1920 125 125 Following should error as overlay isn't within image boundaries 126 126 <DATE><TIME>|<HOST>|E|psLib.image.psImageOverlaySection 127 Specified subset range, [32:<LINENO>,64:<LINENO>], lies outsidepsImage'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>]. 128 128 <DATE><TIME>|<HOST>|I|testImageOverlay 129 129 Following should error as overlay is NULL
Note:
See TracChangeset
for help on using the changeset viewer.
