Changeset 14903
- Timestamp:
- Sep 20, 2007, 9:14:16 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/src/mathtypes/psImage.c
r12813 r14903 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.129 $ $Name: not supported by cvs2svn $12 * @date $Date: 2007-0 4-12 18:52:57$11 * @version $Revision: 1.129.8.1 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-09-20 19:14:16 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "psError.h" 29 29 #include "psAssert.h" 30 #include "psAbort.h" 31 30 32 #include "psImage.h" 31 33 #include "psString.h" … … 38 40 } 39 41 40 if (image->parent != NULL) { 41 psMemBlock* ptr = ((psMemBlock*)image)-1; 42 int ref = ptr->refCounter; 43 ptr->refCounter = 2; // make sure psFree is not retriggered 44 psArrayRemoveData(image->parent->children,image); 45 ptr->refCounter = ref; // restore previous count (not assuming zero, but should be) 46 47 image->parent = NULL; 48 } 49 50 psImageFreeChildren(image); 51 42 psImage *parent = (psImage *) image->parent; 43 44 // if I am a child, remove me from my parent's array of children 45 if (parent != NULL) { 46 // sanity check : a child cannot also be a parent 47 if ((image->children != NULL) && (image->children->n > 0)) { 48 psAbort ("psImage cannot be both child and parent!"); 49 } 50 51 // break the back-pointer first so we don't loop 52 image->parent = NULL; 53 54 // drop my entry on my parent's array of children 55 psArrayRemoveDataNoFree (parent->children, image); 56 57 // drop my reference to my parent 58 psFree (parent); 59 } 60 61 // sanity check: this function should never be reached if an image still has live children; 62 // they should each be holding a pointer to the image, forcing the number of references to 63 // be > 1. 64 if (image->children && (image->children->n > 0)) { 65 psAbort ("psImage memory management programming error : imageFree called on image with live children"); 66 } 67 68 psFree(image->children); 52 69 psFree(image->p_rawDataBuffer); 53 70 psFree(image->data.V); … … 524 541 } 525 542 526 527 int psImageFreeChildren(psImage* image)528 {529 psS32 numFreed = 0;530 531 if (image == NULL) {532 return numFreed;533 }534 535 if (image->children != NULL) {536 psImage** children = (psImage**)image->children->data;537 numFreed = image->children->n;538 539 // orphan the children first540 // (so psFree doesn't try to modify the parent's children array while I'm using it)541 for (psS32 i=0;i<numFreed;i++) {542 children[i]->parent = NULL;543 }544 545 psFree(image->children);546 image->children = NULL;547 }548 549 return numFreed;550 }551 552 543 bool p_psImagePrint (int fd, 553 544 psImage *a,
Note:
See TracChangeset
for help on using the changeset viewer.
