QxOrm  1.4.9
C++ Object Relational Mapping library
mem_leak.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** https://www.qxorm.com/
00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
00005 **
00006 ** This file is part of the QxOrm library
00007 **
00008 ** This software is provided 'as-is', without any express or implied
00009 ** warranty. In no event will the authors be held liable for any
00010 ** damages arising from the use of this software
00011 **
00012 ** Commercial Usage
00013 ** Licensees holding valid commercial QxOrm licenses may use this file in
00014 ** accordance with the commercial license agreement provided with the
00015 ** Software or, alternatively, in accordance with the terms contained in
00016 ** a written agreement between you and Lionel Marty
00017 **
00018 ** GNU General Public License Usage
00019 ** Alternatively, this file may be used under the terms of the GNU
00020 ** General Public License version 3.0 as published by the Free Software
00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the
00022 ** packaging of this file. Please review the following information to
00023 ** ensure the GNU General Public License version 3.0 requirements will be
00024 ** met : http://www.gnu.org/copyleft/gpl.html
00025 **
00026 ** If you are unsure which license is appropriate for your use, or
00027 ** if you have questions regarding the use of this file, please contact :
00028 ** contact@qxorm.com
00029 **
00030 ****************************************************************************/
00031 
00032 /*** http://wyw.dcweb.cn/leakage.htm ***/
00033 
00034 #ifndef QT_NO_DEBUG
00035 #ifndef _QX_MODE_RELEASE
00036 #if _QX_USE_MEM_LEAK_DETECTION
00037 
00038 #define _DEBUG_NEW_REDEFINE_NEW 0
00039 #include "debug_new.h"
00040 
00041 #ifdef _MSC_VER
00042 #pragma warning(disable: 4290) // C++ exception specification ignored
00043 #endif // _MSC_VER
00044 
00045 #ifndef QX_MEM_LEAK_STATIC_OR_INLINE
00046 #ifdef _MSC_VER
00047 #define QX_MEM_LEAK_STATIC_OR_INLINE static
00048 #else
00049 #define QX_MEM_LEAK_STATIC_OR_INLINE inline
00050 #endif // _MSC_VER
00051 #endif // QX_MEM_LEAK_STATIC_OR_INLINE
00052 
00053 QX_MEM_LEAK_STATIC_OR_INLINE void * operator new(size_t size) throw(std::bad_alloc)    { return operator new(size, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0); };
00054 QX_MEM_LEAK_STATIC_OR_INLINE void * operator new[](size_t size) throw(std::bad_alloc)  { return operator new[](size, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0); };
00055 QX_MEM_LEAK_STATIC_OR_INLINE void operator delete(void * pointer) throw()              { qx::memory::__debug_new_recorder::free_pointer(pointer, _DEBUG_NEW_CALLER_ADDRESS, false); };
00056 QX_MEM_LEAK_STATIC_OR_INLINE void operator delete[](void * pointer) throw()            { qx::memory::__debug_new_recorder::free_pointer(pointer, _DEBUG_NEW_CALLER_ADDRESS, true); };
00057 
00058 #if HAVE_PLACEMENT_DELETE
00059 QX_MEM_LEAK_STATIC_OR_INLINE void operator delete(void * pointer, const std::nothrow_t &) throw()     { operator delete(pointer, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0); };
00060 QX_MEM_LEAK_STATIC_OR_INLINE void operator delete[](void * pointer, const std::nothrow_t &) throw()   { operator delete[](pointer, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0); };
00061 #endif // HAVE_PLACEMENT_DELETE
00062 
00063 #ifdef new
00064 #undef new
00065 #endif // new
00066 #define new DEBUG_NEW
00067 
00068 #endif // _QX_USE_MEM_LEAK_DETECTION
00069 #endif // _QX_MODE_RELEASE
00070 #endif // QT_NO_DEBUG
00071 
00072 #if (! _QX_USE_MEM_LEAK_DETECTION)
00073 #ifndef DEBUG_NEW
00074 #define DEBUG_NEW new
00075 #endif // DEBUG_NEW
00076 #endif // (! _QX_USE_MEM_LEAK_DETECTION)
00077 
00078 #ifdef _QX_MODE_RELEASE
00079 #ifndef DEBUG_NEW
00080 #define DEBUG_NEW new
00081 #endif // DEBUG_NEW
00082 #endif // _QX_MODE_RELEASE