QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
mem_leak.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32/*** http://wyw.dcweb.cn/leakage.htm ***/
33
34#ifndef QT_NO_DEBUG
35#ifndef _QX_MODE_RELEASE
36#if _QX_USE_MEM_LEAK_DETECTION
37
38#define _DEBUG_NEW_REDEFINE_NEW 0
39#include "debug_new.h"
40
41#ifdef _MSC_VER
42#pragma warning(disable: 4290) // C++ exception specification ignored
43#endif // _MSC_VER
44
45#ifndef QX_MEM_LEAK_STATIC_OR_INLINE
46#ifdef _MSC_VER
47#define QX_MEM_LEAK_STATIC_OR_INLINE static
48#else
49#define QX_MEM_LEAK_STATIC_OR_INLINE inline
50#endif // _MSC_VER
51#endif // QX_MEM_LEAK_STATIC_OR_INLINE
52
53QX_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); };
54QX_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); };
55QX_MEM_LEAK_STATIC_OR_INLINE void operator delete(void * pointer) throw() { qx::memory::__debug_new_recorder::free_pointer(pointer, _DEBUG_NEW_CALLER_ADDRESS, false); };
56QX_MEM_LEAK_STATIC_OR_INLINE void operator delete[](void * pointer) throw() { qx::memory::__debug_new_recorder::free_pointer(pointer, _DEBUG_NEW_CALLER_ADDRESS, true); };
57
58#if HAVE_PLACEMENT_DELETE
59QX_MEM_LEAK_STATIC_OR_INLINE void operator delete(void * pointer, const std::nothrow_t &) throw() { operator delete(pointer, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0); };
60QX_MEM_LEAK_STATIC_OR_INLINE void operator delete[](void * pointer, const std::nothrow_t &) throw() { operator delete[](pointer, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0); };
61#endif // HAVE_PLACEMENT_DELETE
62
63#ifdef new
64#undef new
65#endif // new
66#define new DEBUG_NEW
67
68#endif // _QX_USE_MEM_LEAK_DETECTION
69#endif // _QX_MODE_RELEASE
70#endif // QT_NO_DEBUG
71
72#if (! _QX_USE_MEM_LEAK_DETECTION)
73#ifndef DEBUG_NEW
74#define DEBUG_NEW new
75#endif // DEBUG_NEW
76#endif // (! _QX_USE_MEM_LEAK_DETECTION)
77
78#ifdef _QX_MODE_RELEASE
79#ifndef DEBUG_NEW
80#define DEBUG_NEW new
81#endif // DEBUG_NEW
82#endif // _QX_MODE_RELEASE
static void free_pointer(void *pointer, void *addr, bool is_array)
#define _DEBUG_NEW_CALLER_ADDRESS
Definition debug_new.h:110
#define QX_MEM_LEAK_STATIC_OR_INLINE
Definition mem_leak.h:49