123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef _SP_COMM_H__
- #define _SP_COMM_H__
- #define _CRTDBG_MAP_ALLOC
- #include <stdlib.h>
- #ifdef RVC_OS_WIN
- #include <crtdbg.h>
- #endif //RVC_OS_WIN
- #include <cstring>
- #include <iostream>
- #include <sstream>
- #include "SpBase.h"
- namespace SP
- {
- /** Leak Detector*/
- namespace Perf
- {
- struct LeakDetector
- {
- LeakDetector()
- {
- #if defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
- flag |= _CRTDBG_LEAK_CHECK_DF;
- flag |= _CRTDBG_ALLOC_MEM_DF;
- _CrtSetDbgFlag(flag);
- #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- }
- ~LeakDetector()
- {
- }
- };
- struct LineLeakDetector
- {
- LineLeakDetector() {
- #if defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- _CrtMemCheckpoint(&s1);
- #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- }
- ~LineLeakDetector()
- {
- #if defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- _CrtMemCheckpoint(&s2);
- if (_CrtMemDifference(&s3, &s1, &s2))
- _CrtMemDumpStatistics(&s3);
- //_CrtDumpMemoryLeaks();
- #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- }
- #if defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- _CrtMemState s1, s2, s3;
- #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG)
- };
- }
- }
- #ifndef ASSERT
- #include <assert.h>
- #define ASSERT assert
- #endif
- #endif // _SP_COMM_H__
|