Changeset 6145
- Timestamp:
- Jan 21, 2006, 5:23:32 PM (20 years ago)
- Location:
- branches/eam_rel9_p0/psModules/src/astrom
- Files:
-
- 4 edited
-
pmChipMosaic.c (modified) (3 diffs)
-
pmFPA.c (modified) (11 diffs)
-
pmFPA.h (modified) (2 diffs)
-
pmFPARead.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c
r6124 r6145 5 5 #include "pmFPA.h" 6 6 #include "pmChipMosaic.h" 7 8 #define MEM_LEAKS 1 7 9 8 10 // Compare a value with a maximum and minimum … … 309 311 310 312 // Chop off all the component cells, and put in a new one 313 #ifndef MEM_LEAKS 314 pmChipFreeCells(chip); 315 #else 316 311 317 chip->cells = psArrayAlloc(0); 318 #endif 319 312 320 pmCell *cell = pmCellAlloc(chip, NULL, __func__); // New cell 313 321 cellConcepts(cell, cells, xBinChip, yBinChip); 314 psFree(cells);315 322 316 323 #if 1 … … 330 337 // Want the readouts to contain a subimage, but that subimage is the whole image. 331 338 // This preserves the relationship there was before, where freeing the parent frees the child. 332 readout->image = ps ImageSubset(image, entire);333 readout->weight = ps ImageSubset(weight, entire);334 readout->mask = ps ImageSubset(mask, entire);339 readout->image = psMemIncrRefCounter(psImageSubset(image, entire)); 340 readout->weight = psMemIncrRefCounter(psImageSubset(weight, entire)); 341 readout->mask = psMemIncrRefCounter(psImageSubset(mask, entire)); 335 342 psFree(readout); 336 343 -
branches/eam_rel9_p0/psModules/src/astrom/pmFPA.c
r6116 r6145 12 12 * XXX: Should we implement non-linear cell->chip transforms? 13 13 * 14 * @version $Revision: 1.1.2. 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-01-2 1 06:47:19$14 * @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-01-22 03:23:32 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 36 36 { 37 37 if (readout != NULL) { 38 #if 0 38 39 psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t) readout->parent); 39 40 if (readout->parent) { … … 41 42 for (int i = 0; i < readouts->n; i++) { 42 43 if (readouts->data[i] == readout) { 44 pmReadout *tmpReadout = readouts->data[i]; 43 45 readouts->data[i] = NULL; 46 psFree(tmpReadout); 44 47 break; 45 48 } 46 49 } 47 50 } 51 #endif 48 52 psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout); 53 54 psFree(readout->parent); 55 49 56 psFree(readout->image); 50 57 psFree(readout->mask); 51 58 psFree(readout->weight); 52 59 psFree(readout->analysis); 53 #if 154 55 psMemDecrRefCounter(readout->parent);56 #endif57 58 60 } 59 61 } … … 62 64 { 63 65 if (cell != NULL) { 66 #if 0 64 67 psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent); 65 68 if (cell->parent) { … … 67 70 for (int i = 0; i < cells->n; i++) { 68 71 if (cells->data[i] == cell) { 72 pmCell *tmpCell = cells->data[i]; 69 73 cells->data[i] = NULL; 74 psFree(tmpCell); 70 75 break; 71 76 } 72 77 } 73 78 } 79 #endif 74 80 psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell); 81 82 pmCellFreeReadouts(cell); 83 psFree(cell->parent); 84 75 85 psFree(cell->toChip); 76 86 psFree(cell->toFPA); … … 79 89 psFree(cell->analysis); 80 90 psFree(cell->camera); 81 #if 182 //83 // Set the parent to NULL in all cell->readouts before psFree(cell->readouts)84 // in order to avoid memory reference counter problems.85 //86 psArray *readouts = cell->readouts;87 for (psS32 i = 0 ; i < readouts->n ; i++) {88 pmReadout *tmpReadout = readouts->data[i];89 readouts->data[i] = NULL;90 tmpReadout->parent = NULL;91 if (PS_FREE_HIERARCHY == 1) {92 psTrace(__func__, 9, "Will now free readout %lx...\n", (size_t)tmpReadout);93 psFree(tmpReadout);94 }95 }96 psMemDecrRefCounter(cell->parent);97 #endif98 99 91 psFree(cell->hdu); 100 92 } … … 104 96 { 105 97 if (chip != NULL) { 98 #if 0 106 99 psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent); 107 100 if (chip->parent) { … … 109 102 for (int i = 0; i < chips->n; i++) { 110 103 if (chips->data[i] == chip) { 104 pmChip *tmpChip = chips->data[i]; 111 105 chips->data[i] = NULL; 106 psFree(tmpChip); 112 107 break; 113 108 } 114 109 } 115 110 } 111 #endif 116 112 psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip); 113 114 pmChipFreeCells(chip); 115 psFree(chip->parent); 117 116 118 117 psFree(chip->toFPA); … … 120 119 psFree(chip->concepts); 121 120 psFree(chip->analysis); 122 #if 1123 //124 // Set the parent to NULL in all chip->cells before psFree(chip->cells)125 // in order to avoid memory reference counter problems.126 //127 psArray *cells = chip->cells;128 for (psS32 i = 0 ; i < cells->n ; i++) {129 pmCell *tmpCell = cells->data[i];130 cells->data[i] = NULL;131 tmpCell->parent = NULL;132 if (PS_FREE_HIERARCHY == 1) {133 psFree(tmpCell);134 }135 }136 psMemDecrRefCounter(chip->parent);137 #endif138 139 121 psFree(chip->hdu); 140 122 } … … 172 154 } 173 155 156 void pmCellFreeReadouts(pmCell *cell) 157 { 158 // 159 // Set the parent to NULL in all cell->readouts before psFree(cell->readouts) 160 // in order to avoid memory reference counter problems. 161 // 162 psArray *readouts = cell->readouts; 163 for (psS32 i = 0 ; i < readouts->n ; i++) { 164 pmReadout *tmpReadout = readouts->data[i]; 165 readouts->data[i] = NULL; 166 tmpReadout->parent = NULL; 167 psTrace(__func__, 9, "Will now free readout %lx...\n", (size_t)tmpReadout); 168 psFree(tmpReadout); // Drop the readout 169 psFree(cell); // Decrement reference counter on cell, since readout->parent isn't held any more 170 } 171 cell->readouts = psArrayRealloc(cell->readouts, 0); 172 } 173 174 175 void pmChipFreeCells(pmChip *chip) 176 { 177 // 178 // Set the parent to NULL in all chip->cells before psFree(chip->cells) 179 // in order to avoid memory reference counter problems. 180 // 181 psArray *cells = chip->cells; 182 for (int i = 0 ; i < cells->n ; i++) { 183 pmCell *tmpCell = cells->data[i]; 184 cells->data[i] = NULL; 185 tmpCell->parent = NULL; 186 pmCellFreeReadouts(tmpCell);// Drop all readouts the cell holds 187 psFree(tmpCell); // Drop the cell 188 psFree(chip); // Decrement reference counter on chip, since cell->parent isn't held any more 189 } 190 chip->cells = psArrayRealloc(chip->cells, 0); 191 } 192 193 194 174 195 void p_pmHDUFree(p_pmHDU *hdu) 175 196 { … … 572 593 573 594 if (! readout->weight) { 574 readout->weight = ps ImageSubset(weights->data[i], *trimsec);595 readout->weight = psMemIncrRefCounter(psImageSubset(weights->data[i], *trimsec)); 575 596 } 576 597 if (! readout->mask) { 577 readout->mask = ps ImageSubset(masks->data[i], *trimsec);598 readout->mask = psMemIncrRefCounter(psImageSubset(masks->data[i], *trimsec)); 578 599 } 579 600 -
branches/eam_rel9_p0/psModules/src/astrom/pmFPA.h
r6080 r6145 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1.1.2. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-01-2 0 09:47:06$9 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-01-22 03:23:32 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 159 159 pmReadout; 160 160 161 void pmCellFreeReadouts(pmCell *cell); 162 void pmChipFreeCells(pmChip *chip); 161 163 162 164 /** Allocates a pmReadout -
branches/eam_rel9_p0/psModules/src/astrom/pmFPARead.c
r6124 r6145 115 115 pmReadout *readout = pmReadoutAlloc(cell); 116 116 117 readout->image = ps ImageSubset(image, *trimsec); // The image corresponding to the trim region117 readout->image = psMemIncrRefCounter(psImageSubset(image, *trimsec)); // The image corresponding to the trim region 118 118 119 119 // Get the list of overscans
Note:
See TracChangeset
for help on using the changeset viewer.
