IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 30, 2005, 4:22:26 PM (21 years ago)
Author:
desonia
Message:

changed psArrayGet/psArraySet/psArrayRemove to do proper reference counting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psMemory.c

    r4971 r5216  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-09-08 00:17:26 $
     10*  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-10-01 02:22:13 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    583583}
    584584
     585psPtr p_psMemSetRefCounter(
     586    psPtr vptr,
     587    psReferenceCount count,
     588    const char *file,
     589    psS32 lineno)
     590{
     591    psMemBlock* ptr;
     592
     593    if (vptr == NULL) {
     594        return vptr;
     595    }
     596
     597    if (count < 0) {
     598        count = 0;
     599    }
     600
     601    ptr = ((psMemBlock* ) vptr) - 1;
     602
     603    if (checkMemBlock(ptr, __func__)) {
     604        memProblemCallback(ptr, file, lineno);
     605    }
     606
     607    pthread_mutex_lock(&ptr->refCounterMutex);
     608    ptr->refCounter = count;
     609    pthread_mutex_unlock(&ptr->refCounterMutex);
     610
     611    if (count < 1) {
     612        vptr = p_psMemDecrRefCounter(vptr,file,lineno);
     613    }
     614
     615    return vptr;
     616}
     617
    585618// decrement and return refCounter
    586619psPtr p_psMemDecrRefCounter(psPtr vptr,
     
    707740    return PTR->freeFunc;
    708741}
    709 
    710742
    711743bool psMemCheckType(psDataType type,
Note: See TracChangeset for help on using the changeset viewer.