123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /*!
- * \file include/memory_test.h
- * Memory testing Toolkit
- *
- * \author Mongoose
- */
-
- #ifndef _MEMORY_TEST_H_
- #define _MEMORY_TEST_H_
-
- #include <cstddef>
-
- #if defined(DEBUG_MEMORY) && !defined(UNIT_TEST_MEMORY)
-
- #define DEBUG_NEW new(__FILE__, __LINE__)
- void *operator new(size_t size, const char *file, int line);
- void *operator new [](size_t size, const char *file, int line);
-
- #define DEBUG_DELETE delete_check(__FILE__, __LINE__, 0);delete
- void operator delete(void *p);
- void operator delete [](void *p);
-
- #else
-
- #define DEBUG_NEW new
- #define DEBUG_DELETE delete
-
- #endif
-
- #define new DEBUG_NEW
- #define delete DEBUG_DELETE
-
- void delete_check(const char *file, int line, int print);
-
- void display_memory_usage();
-
- /*!
- * \brief Get total memory usage
- * \returns amount of total memory used
- */
- long memory_used();
-
- /*!
- * \brief Dumps raw Tree holding memory accounting
- */
- void dump_memory_report();
-
- #ifdef DEBUG_MEMORY
-
- #define DWORD unsigned long
- #define ZERO_ALLOC_SLOTS 3
-
- typedef enum { RB_BLACK = 0, RB_RED = 1 } rbtree_color_t;
-
- typedef struct rbtree_s {
- void *data;
- DWORD key;
- rbtree_color_t color;
- struct rbtree_s *left;
- struct rbtree_s *right;
- struct rbtree_s *parent;
- } rbtree_t;
-
- typedef struct meminfo_filename_s {
- char *filename;
- char filename_len;
- DWORD size;
- unsigned int alloc_zero;
- unsigned short int alloc_zero_at_line[ZERO_ALLOC_SLOTS];
- struct meminfo_filename_s *next;
- } meminfo_filename_t;
-
- #endif
-
- #endif
|