1/* Copyright (c) 2000, 2001, 2003-2006 MySQL AB, 2009 Sun Microsystems, Inc.
2 Use is subject to license terms.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17/*
18 This is a replacement of new/delete operators to be used when compiling
19 with gcc 3.0.x to avoid including libstdc++
20
21 It is also used to make all memory allocations to go through
22 my_malloc/my_free wrappers (for debugging/safemalloc and accounting)
23*/
24
25#include "mysys_priv.h"
26#include <new>
27
28#ifdef USE_MYSYS_NEW
29
30void *operator new (size_t sz)
31{
32 return (void *) my_malloc (sz ? sz : 1, MYF(0));
33}
34
35void *operator new[] (size_t sz)
36{
37 return (void *) my_malloc (sz ? sz : 1, MYF(0));
38}
39
40void* operator new(std::size_t sz, const std::nothrow_t&) throw()
41{
42 return (void *) my_malloc (sz ? sz : 1, MYF(0));
43}
44
45void* operator new[](std::size_t sz, const std::nothrow_t&) throw()
46{
47 return (void *) my_malloc (sz ? sz : 1, MYF(0));
48}
49
50void operator delete (void *ptr, std::size_t)
51{
52 my_free(ptr);
53}
54
55void operator delete (void *ptr)
56{
57 my_free(ptr);
58}
59
60void operator delete[] (void *ptr) throw ()
61{
62 my_free(ptr);
63}
64
65void operator delete[] (void *ptr, std::size_t) throw ()
66{
67 my_free(ptr);
68}
69
70void operator delete(void* ptr, const std::nothrow_t&) throw()
71{
72 my_free(ptr);
73}
74
75void operator delete[](void* ptr, const std::nothrow_t&) throw()
76{
77 my_free(ptr);
78}
79
80C_MODE_START
81
82int __cxa_pure_virtual()
83{
84 assert(! "Aborted: pure virtual method called.");
85 return 0;
86}
87
88C_MODE_END
89#else
90/*
91 Define a dummy symbol, just to avoid compiler/linker warnings
92 about compiling an essentially empty file.
93*/
94int my_new_cc_symbol;
95#endif /* USE_MYSYS_NEW */
96
97