IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10895


Ignore:
Timestamp:
Jan 3, 2007, 12:07:23 PM (19 years ago)
Author:
jhoblitt
Message:

remove failure variable from psMemCheckCorruption() (now unused)
rename checkMemBlock() -> badMemBlock() and change it's return type to bool so that it's usuage is better self documenting

File:
1 edited

Legend:

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

    r10894 r10895  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.88.2.7 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2007-01-03 22:04:42 $
     10*  @version $Revision: 1.88.2.8 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2007-01-03 22:07:23 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6969fprintf(stderr, "\n");
    7070
    71 static psS32 checkMemBlock(const psMemBlock* m, const char *funcName);
     71static bool badMemBlock(const psMemBlock* m, const char *funcName);
    7272static psMemBlock* lastMemBlockAllocated = NULL;
    7373static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
     
    137137 * N.b. If the block wasn't allocated by psAlloc, it will appear corrupted
    138138 */
    139 static psS32 checkMemBlock(const psMemBlock* m,
    140                            const char *funcName)
     139static bool badMemBlock(const psMemBlock* m,
     140                        const char *funcName)
    141141{
    142142    // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked,
     
    146146        PS_MEM_ERROR(PS_ERR_MEMORY_CORRUPTION, true,
    147147                     _("NULL memory block found."));
    148         return 1;
     148        return true;
    149149    }
    150150
     
    154154                     _("Memory block %lu was freed but still being used."),
    155155                     (unsigned long)m->id);
    156         return 1;
     156        return true;
    157157    }
    158158
     
    161161                     _("Memory block %lu is corrupted; buffer underflow detected."),
    162162                     (unsigned long)m->id);
    163         return 1;
     163        return true;
    164164    }
    165165    if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
     
    167167                     _("Memory block %lu is corrupted; buffer overflow detected."),
    168168                     (unsigned long)m->id);
    169         return 1;
    170     }
    171 
    172     return 0;
     169        return true;
     170    }
     171
     172    return false;
    173173}
    174174
     
    303303{
    304304    psS32 nbad = 0;               // number of bad blocks
    305     psBool failure = false;
    306305
    307306    // get exclusive access to the memBlock list to avoid it changing on us
     
    310309
    311310    for (psMemBlock* iter = lastMemBlockAllocated; iter != NULL; iter = iter->nextBlock) {
    312         if (checkMemBlock(iter, __func__)) {
     311        if (badMemBlock(iter, __func__)) {
    313312            nbad++;
    314313
     
    413412    psMemBlock *ptr = ((psMemBlock*)vptr) - 1;
    414413
    415     if (checkMemBlock(ptr, __func__) != 0) {
     414    if (badMemBlock(ptr, __func__) != 0) {
    416415        memProblemCallback(ptr, file, lineno);
    417416        PS_MEM_ABORT(file, "Realloc detected a memory corruption (id %lu @ %s:%d).",
     
    477476    }
    478477
    479     if (checkMemBlock(ptr, __func__) != 0) {
     478    if (badMemBlock(ptr, __func__) != 0) {
    480479        memProblemCallback(ptr, filename, lineno);
    481480        PS_MEM_ABORT(__func__,"Memory Corruption Detected.");
     
    558557    ptr2 = ((psMemBlock* ) ptr) - 1;
    559558
    560     if (checkMemBlock(ptr2, __func__) != 0) {
     559    if (badMemBlock(ptr2, __func__) != 0) {
    561560        memProblemCallback(ptr2, __func__, __LINE__);
    562561    }
     
    582581    ptr = ((psMemBlock* ) vptr) - 1;
    583582
    584     if (checkMemBlock(ptr, __func__)) {
     583    if (badMemBlock(ptr, __func__)) {
    585584        memProblemCallback(ptr, file, lineno);
    586585    }
     
    615614    ptr = ((psMemBlock* ) vptr) - 1;
    616615
    617     if (checkMemBlock(ptr, __func__)) {
     616    if (badMemBlock(ptr, __func__)) {
    618617        memProblemCallback(ptr, file, lineno);
    619618    }
     
    641640    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    642641
    643     if (checkMemBlock(ptr, __func__) != 0) {
     642    if (badMemBlock(ptr, __func__) != 0) {
    644643        memProblemCallback(ptr, file, lineno);
    645644        return NULL;
     
    694693    psMemBlock* PTR = ((psMemBlock* ) ptr) - 1;
    695694
    696     if (checkMemBlock(PTR, __func__) != 0) {
     695    if (badMemBlock(PTR, __func__) != 0) {
    697696        memProblemCallback(PTR, __func__, __LINE__);
    698697    }
     
    710709    psMemBlock* PTR = ((psMemBlock* ) ptr) - 1;
    711710
    712     if (checkMemBlock(PTR, __func__) != 0) {
     711    if (badMemBlock(PTR, __func__) != 0) {
    713712        memProblemCallback(PTR, __func__, __LINE__);
    714713    }
     
    10061005    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    10071006
    1008     if (checkMemBlock(ptr, __func__) != 0) {
     1007    if (badMemBlock(ptr, __func__) != 0) {
    10091008        memProblemCallback(ptr, __func__, __LINE__);
    10101009    }
     
    10221021    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    10231022
    1024     if (checkMemBlock(ptr, __func__) != 0) {
     1023    if (badMemBlock(ptr, __func__) != 0) {
    10251024        memProblemCallback(ptr, __func__, __LINE__);
    10261025    }
Note: See TracChangeset for help on using the changeset viewer.