IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10890


Ignore:
Timestamp:
Jan 3, 2007, 11:43:57 AM (19 years ago)
Author:
jhoblitt
Message:

add psErrorStackGetNoAlloc()
change psErrorStackPrint() to use psErrorStackGetNoAlloc() so that it's safe to be called from inside of psMemory.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/jch-memory/psLib/src/sys/psError.c

    r9730 r10890  
    1111 *  @author Eric Van Alst, MHPCC
    1212 *
    13  *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-10-24 22:52:56 $
     13 *  @version $Revision: 1.41.2.1 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2007-01-03 21:43:57 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    9898}
    9999
     100// This function serves the same purpose of psErrorStackGet() accept it does
     101// not alloc the error stack if it DOES NOT already exist.  Unlike
     102// psErrorStackGet(), this function is NOT guarenteed to return a valid pointer
     103// and it's return status must be checked.
     104static psArray *psErrorStackGetNoAlloc(void)
     105{
     106    // check to see if the error stack key has been initialized
     107    pthread_mutex_lock(&lockErrorStack);
     108    if (errorStackKeyInitialized == false) {
     109        return NULL;
     110    }
     111    pthread_mutex_unlock(&lockErrorStack);
     112
     113    // check to see if the error stack for this thread has been allocated
     114    psArray *errorStack = NULL;
     115    if ((errorStack = pthread_getspecific(errorStack_key)) == NULL) {
     116        return NULL;
     117    }
     118
     119    return errorStack;
     120}
     121
    100122static void psErrFree(psErr* err)
    101123{
     
    260282}
    261283
     284// This function does not allocate any memory so it is safe to call from inside
     285// of psMemory.c.  Do not allocate memory in function (or call any functions
     286// that do) without first removing it's use from psMemory.c.
    262287void psErrorStackPrintV(FILE *fd, const char *format, va_list va)
    263288{
    264     psArray *errorStack = psErrorStackGet();
     289    psArray *errorStack = psErrorStackGetNoAlloc();
     290    // do nothing if there error stack has not been allocated
     291    if (!errorStack) {
     292        return;
     293    }
    265294
    266295    vfprintf(fd, format, va);
Note: See TracChangeset for help on using the changeset viewer.