IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 227


Ignore:
Timestamp:
Mar 12, 2004, 3:10:01 PM (22 years ago)
Author:
rhl
Message:

Allow memory.c to use malloc/realloc/free; don't try to free bad pointers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/src/Utils/memory.c

    r175 r227  
    44#include "psUtils.h"
    55#include "Private/p_psMemory.h"
     6
     7#undef malloc                           // _We_ are allowed to call these
     8#undef realloc
     9#undef free
    610
    711#undef psAlloc                          // don't get the __FILE__ versions
     
    292296    }
    293297
    294     if (bad_memblock(ptr, 0) || ptr->refCounter != 1) {
    295         memProblemCB(ptr, file, lineno);
    296     }
    297 
    298     ptr->refCounter--;
    299     memBlocks[ptr->id] = NULL;          // XXX sub-optimal! Can't check
    300                                         // freed blocks for corruption
    301     free(ptr);
     298    if (bad_memblock(ptr, 0)) {
     299        memProblemCB(ptr, file, lineno); // we may not own this block; don't free it
     300    } else {
     301        if (ptr->refCounter != 1) {
     302            memProblemCB(ptr, file, lineno);
     303        }
     304        ptr->refCounter--;
     305        memBlocks[ptr->id] = NULL;      // XXX sub-optimal! Can't check
     306                                        // freed blocks for corruption
     307        free(ptr);
     308    }
    302309}
    303310
Note: See TracChangeset for help on using the changeset viewer.