IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 29, 2006, 7:58:21 AM (19 years ago)
Author:
rhl
Message:

Added memAllocCallbackCheckCorruption which can be registered as an memAllocCallback to periodically check the heap

File:
1 edited

Legend:

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

    r9538 r10276  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.86 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2006-10-13 21:13:48 $
     10*  @version $Revision: 1.87 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-11-29 17:58:21 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    182182}
    183183
     184
     185/*
     186 * A callback function to check the state of the memory system; may be registered
     187 * with psMem{Alloc,Free}CallbackSet
     188 */
     189static psMemId memAllocCallbackCheckCorruption(const psMemBlock *ptr)
     190{
     191    static psMemId incr = 10; // "p_psMemAllocID += incr"
     192    bool abort_on_error = false;
     193
     194    if (psMemCheckCorruption(abort_on_error) > 0) {
     195        fprintf(stderr,"Detected memory corruption\n"); // somewhere to set a breakpoint
     196    }
     197
     198    return incr;
     199}
     200
    184201/*
    185202 * The default callbacks
     
    227244{
    228245    psMemId old = p_psMemAllocID;
     246
     247    /*
     248     * This is here purely to stop gcc complaining
     249     */
     250    assert (memAllocCallbackCheckCorruption != NULL);
    229251
    230252    p_psMemAllocID = id;
Note: See TracChangeset for help on using the changeset viewer.