Changeset 700
- Timestamp:
- May 14, 2004, 4:10:27 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
image/psImage.c (modified) (4 diffs)
-
image/psImage.h (modified) (3 diffs)
-
mathtypes/psImage.c (modified) (4 diffs)
-
mathtypes/psImage.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImage.c
r693 r700 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05-15 0 0:14:56$9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-15 02:10:27 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 65 65 void psImageFree(psImage *image) 66 66 { 67 int i = 0; 68 int nChildren = 0; 69 psImage **children = NULL; 70 71 if(image != NULL) { 72 nChildren = image->nChildren; 73 children = image->children; 74 75 for(i=0; i<nChildren; i++) { 76 psImageFree(children[i]); 77 } 78 79 psFree(image->data.v[0]); 80 psFree(image->data.v); 81 82 } 67 psImageFreeChildren(image); 68 psImageFreePixels(image); 69 psFree(image); 83 70 } 84 71 … … 91 78 unsigned int inputColOffset; // offset in bytes to first subset pixel in input row 92 79 93 if (image == NULL ) {94 psError(__func__,"Can not subset image because input image is NULL.");80 if (image == NULL || image->data.v == NULL) { 81 psError(__func__,"Can not subset image because input image or its pixel buffer is NULL."); 95 82 return NULL; 96 83 } … … 139 126 return (out); 140 127 } 128 129 void psImageFreePixels(psImage *restrict image) 130 { 131 if (image == NULL || image->data.v == NULL) { 132 return; 133 } 134 135 psFree(image->data.v[0]); 136 psFree(image->data.v); 137 image->data.v = NULL; 138 139 // xxx - is this proper? 140 *(unsigned int*)&image->numRows = 0; 141 *(unsigned int*)&image->numCols = 0; 142 } 143 144 int psImageFreeChildren(psImage* image) 145 { 146 int i = 0; 147 int nChildren = 0; 148 psImage **children = NULL; 149 int numFreed = 0; 150 151 if (image == NULL) { 152 return numFreed; 153 } 154 155 nChildren = image->nChildren; 156 children = image->children; 157 158 for(i=0; i<nChildren; i++) { 159 if (children[i] != NULL) { 160 numFreed++; 161 psImageFree(children[i]); 162 } 163 } 164 165 return numFreed; 166 } -
trunk/psLib/src/image/psImage.h
r692 r700 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05-1 4 22:39:58$9 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-15 02:10:27 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 99 99 * Uses psLib memory deallocation functions to free an image and any existing children. 100 100 * 101 * @return psImage*: Pointer to psImage.102 *103 101 */ 104 102 void psImageFree( … … 106 104 ); 107 105 106 /** Deallocate the image buffer of a psImage. 107 * 108 * deallocates the image buffer while preserving the psImage struct and any children. 109 * 110 */ 111 void psImageFreePixels( 112 psImage *restrict image ///< psImage to free pixel memory from 113 ); 114 115 /** Frees all children of a psImage. 116 * 117 * return int Number of children freed. 118 * 119 */ 120 int psImageFreeChildren( 121 psImage* image ///< psImage in which all children shall be deallocated 122 ); 123 124 125 108 126 #endif -
trunk/psLib/src/mathtypes/psImage.c
r693 r700 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05-15 0 0:14:56$9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-15 02:10:27 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 65 65 void psImageFree(psImage *image) 66 66 { 67 int i = 0; 68 int nChildren = 0; 69 psImage **children = NULL; 70 71 if(image != NULL) { 72 nChildren = image->nChildren; 73 children = image->children; 74 75 for(i=0; i<nChildren; i++) { 76 psImageFree(children[i]); 77 } 78 79 psFree(image->data.v[0]); 80 psFree(image->data.v); 81 82 } 67 psImageFreeChildren(image); 68 psImageFreePixels(image); 69 psFree(image); 83 70 } 84 71 … … 91 78 unsigned int inputColOffset; // offset in bytes to first subset pixel in input row 92 79 93 if (image == NULL ) {94 psError(__func__,"Can not subset image because input image is NULL.");80 if (image == NULL || image->data.v == NULL) { 81 psError(__func__,"Can not subset image because input image or its pixel buffer is NULL."); 95 82 return NULL; 96 83 } … … 139 126 return (out); 140 127 } 128 129 void psImageFreePixels(psImage *restrict image) 130 { 131 if (image == NULL || image->data.v == NULL) { 132 return; 133 } 134 135 psFree(image->data.v[0]); 136 psFree(image->data.v); 137 image->data.v = NULL; 138 139 // xxx - is this proper? 140 *(unsigned int*)&image->numRows = 0; 141 *(unsigned int*)&image->numCols = 0; 142 } 143 144 int psImageFreeChildren(psImage* image) 145 { 146 int i = 0; 147 int nChildren = 0; 148 psImage **children = NULL; 149 int numFreed = 0; 150 151 if (image == NULL) { 152 return numFreed; 153 } 154 155 nChildren = image->nChildren; 156 children = image->children; 157 158 for(i=0; i<nChildren; i++) { 159 if (children[i] != NULL) { 160 numFreed++; 161 psImageFree(children[i]); 162 } 163 } 164 165 return numFreed; 166 } -
trunk/psLib/src/mathtypes/psImage.h
r692 r700 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05-1 4 22:39:58$9 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-15 02:10:27 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 99 99 * Uses psLib memory deallocation functions to free an image and any existing children. 100 100 * 101 * @return psImage*: Pointer to psImage.102 *103 101 */ 104 102 void psImageFree( … … 106 104 ); 107 105 106 /** Deallocate the image buffer of a psImage. 107 * 108 * deallocates the image buffer while preserving the psImage struct and any children. 109 * 110 */ 111 void psImageFreePixels( 112 psImage *restrict image ///< psImage to free pixel memory from 113 ); 114 115 /** Frees all children of a psImage. 116 * 117 * return int Number of children freed. 118 * 119 */ 120 int psImageFreeChildren( 121 psImage* image ///< psImage in which all children shall be deallocated 122 ); 123 124 125 108 126 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
