inc/memalloc.h

Go to the documentation of this file.
00001 /* Let the user redirect where memory allocation/deallocation
00002  * happens.  'careful' routines help debug scrambled heaps. 
00003  *
00004  * This file is copyright 2002 Jim Kent, but license is hereby
00005  * granted for all use - public, private or commercial. */
00006 
00007 #ifndef MEMALLOC_H
00008 #define MEMALLOC_H
00009 
00010 struct memHandler
00011     {
00012     struct memHandler *next;
00013     void * (*alloc)(size_t size);
00014     void (*free)(void *vpt);
00015     void * (*realloc)(void* vpt, size_t size);
00016     };
00017 
00018 struct memHandler *pushMemHandler(struct memHandler *newHandler);
00019 /* Use newHandler for memory requests until matching popMemHandler.
00020  * Returns previous top of memory handler stack. */
00021 
00022 struct memHandler *popMemHandler();
00023 /* Removes top element from memHandler stack and returns it. */
00024 
00025 void setDefaultMemHandler();
00026 /* Sets memHandler to the default. */
00027 
00028 void pushCarefulMemHandler(size_t maxAlloc);
00029 /* Push the careful (paranoid, conservative, checks everything)
00030  * memory handler  top of the memHandler stack and use it. */
00031 
00032 void carefulCheckHeap();
00033 /* Walk through allocated memory and make sure that all cookies are
00034  * in place. Only walks through what's been done since 
00035  * pushCarefulMemHandler(). */
00036 
00037 int carefulCountBlocksAllocated();
00038 /* How many memory items are allocated? (Since called
00039  * pushCarefulMemHandler(). */
00040 
00041 long carefulTotalAllocated();
00042 /* Return total bases allocated */
00043 
00044 void setMaxAlloc(size_t s);
00045 /* Set large allocation limit. */
00046 
00047 void memTrackerStart();
00048 /* Push memory handler that will track blocks allocated so that
00049  * they can be automatically released with memTrackerEnd().  */
00050 
00051 void memTrackerEnd();
00052 /* Free any remaining blocks and pop tracker memory handler. */
00053 
00054 #endif /* MEMALLOC_H */
00055 

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2