IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2009, 3:05:58 PM (17 years ago)
Author:
eugene
Message:

added mutexes to protect the psImage children management

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageStructManip.c

    r15492 r21347  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2007-11-08 01:09:48 $
     10 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-02-06 01:05:58 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2121#include <string.h>
    2222#include <assert.h>
     23#include <errno.h>
    2324
    2425#include "psMemory.h"
    2526#include "psError.h"
    2627#include "psAbort.h"
     28#include "psTrace.h"
    2729
    2830#include "psImageStructManip.h"
     
    108110
    109111            // drop my entry on my parent's array of children
     112            psMutexLock (out);
    110113            psArrayRemoveDataNoFree (out->parent->children, out);
     114            psMutexUnlock (out);
    111115
    112116            // drop my reference to my old parent
     
    119123        out = p_psAlloc(file, lineno, func, sizeof(psImage));
    120124        out->data.V = NULL;
     125        psMutexInit (out);
    121126    }
    122127
     
    129134    P_PSIMAGE_SET_ROW0(out, row0);
    130135
     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)
    131138    out->parent = psMemIncrRefCounter(image); // track references to parents
    132139    out->children = NULL;
     
    144151    }
    145152
    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);
    147156    image->children = p_psArrayAdd(file, lineno, func, image->children, 16, out);
     157    psMutexUnlock (image);
     158
    148159    psFree (out); // the image->children array is an array of views only
    149 
    150160    return (out);
    151161}
     
    369379    P_PSIMAGE_SET_NUMROWS(image, numRows);
    370380
    371     // XXX: should I really resize the buffers?
     381    // resize the buffers to the new image size
    372382    image->data.V = psRealloc(image->data.V,sizeof(psPtr)*numRows);
    373383    image->p_rawDataBuffer = psRealloc(image->p_rawDataBuffer,rowSize*numRows);
Note: See TracChangeset for help on using the changeset viewer.