MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sql_alloc.h
1 #ifndef SQL_ALLOC_INCLUDED
2 #define SQL_ALLOC_INCLUDED
3 /* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software Foundation,
16  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
17 
18 #include "thr_malloc.h"
19 #include "my_sys.h"
20 #include "m_string.h"
21 
26 class Sql_alloc
27 {
28 public:
29  static void *operator new(size_t size) throw ()
30  {
31  return sql_alloc(size);
32  }
33  static void *operator new[](size_t size) throw ()
34  {
35  return sql_alloc(size);
36  }
37  static void *operator new[](size_t size, MEM_ROOT *mem_root) throw ()
38  { return alloc_root(mem_root, size); }
39  static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
40  { return alloc_root(mem_root, size); }
41  static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); }
42  static void operator delete(void *ptr, MEM_ROOT *mem_root)
43  { /* never called */ }
44  static void operator delete[](void *ptr, MEM_ROOT *mem_root)
45  { /* never called */ }
46  static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); }
47 #ifdef HAVE_purify
48  bool dummy;
49  inline Sql_alloc() :dummy(0) {}
50  inline ~Sql_alloc() {}
51 #else
52  inline Sql_alloc() {}
53  inline ~Sql_alloc() {}
54 #endif
55 
56 };
57 
58 #endif // SQL_ALLOC_INCLUDED