summaryrefslogtreecommitdiffstats
path: root/include/common.h
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-24 07:34:33 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-24 07:34:33 +0000
commit2d76b271c36ca347917c91bc22e812d9c786315d (patch)
tree507977ceb617bcb577c9054773a391b8d1dd446c /include/common.h
parent1db4a2b12e33f801842bd060ecc7b3b06d664dd1 (diff)
downloadzabbix-2d76b271c36ca347917c91bc22e812d9c786315d.tar.gz
zabbix-2d76b271c36ca347917c91bc22e812d9c786315d.tar.xz
zabbix-2d76b271c36ca347917c91bc22e812d9c786315d.zip
- added delta value calculation for UINT64 (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@4164 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index 6890ff20..d2f79258 100644
--- a/include/common.h
+++ b/include/common.h
@@ -28,6 +28,50 @@
# define SDI2(msg,p1) fprintf(stderr, "%6i:DEBUG INFO: " msg "\n", getpid(), p1); fflush(stderr);
#endif
+#if defined(ENABLE_CHECK_MEMOTY)
+# include "crtdbg.h"
+
+# define REINIT_CHECK_MEMORY() \
+ _CrtMemCheckpoint(&oldMemState)
+
+# define INIT_CHECK_MEMORY() \
+ char DumpMessage[0x1FF]; \
+ _CrtMemState oldMemState, newMemState, diffMemState; \
+ REINIT_CHECK_MEMORY()
+
+# define CHECK_MEMORY(fncname, msg) \
+ DumpMessage[0] = '\0'; \
+ _CrtMemCheckpoint(&newMemState); \
+ if(_CrtMemDifference(&diffMemState, &oldMemState, &newMemState)) \
+ { \
+ zbx_snprintf(DumpMessage, sizeof(DumpMessage), \
+ "%s\n" \
+ "free: %10li bytes in %10li blocks\n" \
+ "normal:%10li bytes in %10li blocks\n" \
+ "CRT: %10li bytes in %10li blocks\n", \
+ \
+ fncname ": Memory changed! (" msg ")\n", \
+ \
+ (long) diffMemState.lSizes[_FREE_BLOCK], \
+ (long) diffMemState.lCounts[_FREE_BLOCK], \
+ \
+ (long) diffMemState.lSizes[_NORMAL_BLOCK], \
+ (long) diffMemState.lCounts[_NORMAL_BLOCK], \
+ \
+ (long) diffMemState.lSizes[_CRT_BLOCK], \
+ (long) diffMemState.lCounts[_CRT_BLOCK]); \
+ } \
+ else \
+ { \
+ zbx_snprintf(DumpMessage, sizeof(DumpMessage), \
+ "%s: Memory OK! (%s)", fncname, msg); \
+ } \
+ SDI2("MEMORY_LEAK: %s", DumpMessage)
+#else
+# define INIT_CHECK_MEMORY() ((void)0)
+# define CHECK_MEMORY(fncname, msg) ((void)0)
+#endif
+
#include "sysinc.h"
#include "zbxtypes.h"