Changeset 21294
- Timestamp:
- Feb 4, 2009, 1:36:56 PM (17 years ago)
- Location:
- branches/eam_branch_20090203/psLib/src
- Files:
-
- 2 edited
-
imageops/psImageStructManip.c (modified) (7 diffs)
-
mathtypes/psImage.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20090203/psLib/src/imageops/psImageStructManip.c
r15492 r21294 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $11 * @date $Date: 200 7-11-08 01:09:48$10 * @version $Revision: 1.20.42.1 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-02-04 23:36:56 $ 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" … … 100 102 psPtr rawData = psMemIncrRefCounter(image->p_rawDataBuffer); 101 103 104 // XXX worry about this later... 102 105 if (out != NULL) { 103 106 // if a child, need to orphan (disassociate from parent) first … … 108 111 109 112 // drop my entry on my parent's array of children 113 psMutexLock (out); 110 114 psArrayRemoveDataNoFree (out->parent->children, out); 115 psMutexUnlock (out); 111 116 112 117 // drop my reference to my old parent … … 119 124 out = p_psAlloc(file, lineno, func, sizeof(psImage)); 120 125 out->data.V = NULL; 126 psMutexInit (out); 121 127 } 122 128 … … 129 135 P_PSIMAGE_SET_ROW0(out, row0); 130 136 137 // As long as I have a valid image reference, no one else can free it to zero (I have at 138 // least the last reference) 131 139 out->parent = psMemIncrRefCounter(image); // track references to parents 132 140 out->children = NULL; … … 144 152 } 145 153 146 // add output image as a child of the input image. 154 // Add output image as a child of the input image. Lock image before performing this 155 // operation (psArrayAdd is NOT thread-safe) 156 psMutexLock (image); 147 157 image->children = p_psArrayAdd(file, lineno, func, image->children, 16, out); 158 psMutexUnlock (image); 159 148 160 psFree (out); // the image->children array is an array of views only 149 150 161 return (out); 151 162 } -
branches/eam_branch_20090203/psLib/src/mathtypes/psImage.c
r20547 r21294 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.132 $ $Name: not supported by cvs2svn $12 * @date $Date: 200 8-11-05 11:12:39$11 * @version $Revision: 1.132.10.1 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-02-04 23:36:56 $ 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 a test : we will add a mutex to all images: 132 psMutexInit (image); 124 133 125 134 return image;
Note:
See TracChangeset
for help on using the changeset viewer.
