memory_checker.h

Go to the documentation of this file.
00001 #ifndef MEMORY_CHECKER_CLASS
00002 #define MEMORY_CHECKER_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : memory_checker                                                    *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1998-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "definitions.h"
00019 
00020 #ifdef ENABLE_MEMORY_HOOK
00021 
00022 #include "build_configuration.h"
00023 
00024 // forward.
00025 class allocation_memories;
00026 class memory_checker;
00027 
00029 
00030 memory_checker BASIS_EXTERN &program_wide_memories();
00032 
00036 
00037 
00039 
00050 class memory_checker
00051 {
00052 public:
00053   void construct();  
00054 
00055   void destruct();  
00056 
00058   void disable() { _enabled = false; }
00060   void enable() { _enabled = true; }
00062   bool enabled() const { return _enabled; }
00063 
00064   void *provide_memory(size_t size, char *file, int line);
00066 
00072   int release_memory(void *ptr);
00074 
00079   char *text_form(bool show_outstanding);
00081 
00085 private:
00086   allocation_memories *_mems;  
00087   bool _unusable;  
00088   bool _enabled;  
00089 };
00090 
00091 #else // enable memory hook.
00092   // this section disables the memory checker entirely.
00093   #define program_wide_memories()
00094     // define a do nothing macro for the global memory tracker.
00095 #endif // enable memory hook.
00096 
00097 #endif // outer guard.
00098 

Generated on Fri Sep 5 04:28:36 2008 for HOOPLE Libraries by  doxygen 1.5.1