Changeset 21347
- Timestamp:
- Feb 5, 2009, 3:05:58 PM (17 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
imageops/psImageStructManip.c (modified) (7 diffs)
-
mathtypes/psImage.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageStructManip.c
r15492 r21347 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $11 * @date $Date: 200 7-11-08 01:09:48 $10 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-02-06 01:05:58 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 21 21 #include <string.h> 22 22 #include <assert.h> 23 #include <errno.h> 23 24 24 25 #include "psMemory.h" 25 26 #include "psError.h" 26 27 #include "psAbort.h" 28 #include "psTrace.h" 27 29 28 30 #include "psImageStructManip.h" … … 108 110 109 111 // drop my entry on my parent's array of children 112 psMutexLock (out); 110 113 psArrayRemoveDataNoFree (out->parent->children, out); 114 psMutexUnlock (out); 111 115 112 116 // drop my reference to my old parent … … 119 123 out = p_psAlloc(file, lineno, func, sizeof(psImage)); 120 124 out->data.V = NULL; 125 psMutexInit (out); 121 126 } 122 127 … … 129 134 P_PSIMAGE_SET_ROW0(out, row0); 130 135 136 // As long as I have a valid image reference, no one else can free it to zero (I have at 137 // least the last reference) 131 138 out->parent = psMemIncrRefCounter(image); // track references to parents 132 139 out->children = NULL; … … 144 151 } 145 152 146 // add output image as a child of the input image. 153 // Add output image as a child of the input image. Lock image before performing this 154 // operation (psArrayAdd is NOT thread-safe) 155 psMutexLock (image); 147 156 image->children = p_psArrayAdd(file, lineno, func, image->children, 16, out); 157 psMutexUnlock (image); 158 148 159 psFree (out); // the image->children array is an array of views only 149 150 160 return (out); 151 161 } … … 369 379 P_PSIMAGE_SET_NUMROWS(image, numRows); 370 380 371 // XXX: should I really resize the buffers?381 // resize the buffers to the new image size 372 382 image->data.V = psRealloc(image->data.V,sizeof(psPtr)*numRows); 373 383 image->p_rawDataBuffer = psRealloc(image->p_rawDataBuffer,rowSize*numRows); -
trunk/psLib/src/mathtypes/psImage.c
r20547 r21347 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.13 2$ $Name: not supported by cvs2svn $12 * @date $Date: 200 8-11-05 11:12:39$11 * @version $Revision: 1.133 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-02-06 01:05:58 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include <math.h> 25 25 #include <unistd.h> 26 #include <errno.h> 26 27 27 28 #include "psMemory.h" … … 29 30 #include "psAssert.h" 30 31 #include "psAbort.h" 32 #include "psTrace.h" 31 33 32 34 #include "psImage.h" … … 53 55 54 56 // drop my entry on my parent's array of children 57 // lock parent before freeing child : psArrayRemoveDataNoFree is NOT thread safe 58 psMutexLock (parent); 55 59 psArrayRemoveDataNoFree (parent->children, image); 60 psMutexUnlock (parent); 56 61 57 62 // drop my reference to my parent … … 66 71 } 67 72 73 psMutexDestroy(image); 68 74 psFree(image->children); 69 75 psFree(image->p_rawDataBuffer); … … 122 128 image->parent = NULL; 123 129 image->children = NULL; 130 131 // XXX for now, we will add a mutex to all images. in the future, allow images to be 132 // threaded or unthreaded independently? 133 psMutexInit (image); 124 134 125 135 return image;
Note:
See TracChangeset
for help on using the changeset viewer.
