IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2007, 6:46:32 PM (19 years ago)
Author:
jhoblitt
Message:

add PS_MEM_ABORT macro
replace all usage of psAbort() with PS_MEM_ABORT

File:
1 edited

Legend:

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

    r10887 r10888  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.88.2.3 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2007-01-03 04:30:32 $
     10*  @version $Revision: 1.88.2.4 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2007-01-03 04:46:32 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psError.h"
    2626#include "psAssert.h"
    27 #include "psAbort.h"
    2827#include "psLogMsg.h"
    2928#include "psBitSet.h"
     
    4847}
    4948
     49// psAbort() calls functions that call psAlloc() so it is *UNSAFE* to use it
     50// from within the memory subsystem.  Previous implementations tried to do
     51// this and would deadlock while trying to allocate memory.
     52#define PS_MEM_ABORT(name, ...) \
     53fprintf(stderr, "Memory Management Error. This error can not be logged.\n") ;\
     54fprintf(stderr, __VA_ARGS__);\
     55fprintf(stderr, "\n");\
     56abort();
     57
    5058static psS32 checkMemBlock(const psMemBlock* m, const char *funcName);
    5159static psMemBlock* lastMemBlockAllocated = NULL;
     
    107115
    108116    if (lineno > 0) {
    109         psAbort(__func__, "Detected a problem in the memory system at %s:%d", file, lineno);
     117        PS_MEM_ABORT(__func__, "Detected a problem in the memory system at %s:%d", file, lineno);
    110118    }
    111119}
     
    299307                // release the lock on the memblock list
    300308                MUTEX_UNLOCK(&memBlockListMutex);
    301                 psAbort(__func__, "Detected memory corruption");
     309                PS_MEM_ABORT(__func__, "Detected memory corruption");
    302310                return nbad;
    303311            }
     
    338346            ptr = memExhaustedCallback(size);
    339347            if (ptr == NULL) {
    340                 psAbort(__func__, "Failed to allocate %zd bytes at %s:%d", size, file, lineno);
     348                PS_MEM_ABORT(__func__, "Failed to allocate %zd bytes at %s:%d", size, file, lineno);
    341349            }
    342350        }
     
    396404    if (checkMemBlock(ptr, __func__) != 0) {
    397405        memProblemCallback(ptr, file, lineno);
    398         psAbort(file, "Realloc detected a memory corruption (id %lu @ %s:%d).",
    399                 (unsigned long)ptr->id, ptr->file, ptr->lineno);
     406        PS_MEM_ABORT(file, "Realloc detected a memory corruption (id %lu @ %s:%d).",
     407                     (unsigned long)ptr->id, ptr->file, ptr->lineno);
    400408    }
    401409
     
    414422        ptr = memExhaustedCallback(size);
    415423        if (ptr == NULL) {
    416             psAbort(__func__, "Failed to reallocate %zd bytes at %s:%d", size, file, lineno);
     424            PS_MEM_ABORT(__func__, "Failed to reallocate %zd bytes at %s:%d", size, file, lineno);
    417425        }
    418426    }
     
    454462        psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    455463
    456         psAbort(__func__,_("Block %lu, allocated at %s:%d, freed multiple times at %s:%d."),
    457                 (unsigned long)ptr->id, ptr->file, ptr->lineno, filename, lineno);
     464        PS_MEM_ABORT(__func__,_("Block %lu, allocated at %s:%d, freed multiple times at %s:%d."),
     465                     (unsigned long)ptr->id, ptr->file, ptr->lineno, filename, lineno);
    458466    }
    459467
    460468    if (checkMemBlock(ptr, __func__) != 0) {
    461469        memProblemCallback(ptr, filename, lineno);
    462         psAbort(__func__,"Memory Corruption Detected.");
     470        PS_MEM_ABORT(__func__,"Memory Corruption Detected.");
    463471    }
    464472
Note: See TracChangeset for help on using the changeset viewer.