Drizzled Public API Documentation

sql_alloc.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #pragma once
21 
22 #include <drizzled/memory/root.h>
23 #include <drizzled/visibility.h>
24 
25 namespace drizzled {
26 namespace memory {
27 
28 void* sql_alloc(size_t);
29 void* sql_calloc(size_t);
30 char* sql_strdup(const char*);
31 char* sql_strdup(str_ref);
32 void* sql_memdup(const void*, size_t);
33 
35 {
36 public:
37  static void* operator new(size_t size)
38  {
39  return memory::sql_alloc(size);
40  }
41 
42  static void* operator new[](size_t size)
43  {
44  return memory::sql_alloc(size);
45  }
46 
47  static void* operator new(size_t size, Root& root)
48  {
49  return root.alloc(size);
50  }
51 
52  static void* operator new[](size_t size, Root& root)
53  {
54  return root.alloc(size);
55  }
56 
57  static void* operator new(size_t size, Root* root)
58  {
59  return root->alloc(size);
60  }
61 
62  static void* operator new[](size_t size, Root* root)
63  {
64  return root->alloc(size);
65  }
66 
67  static void operator delete(void*)
68  {
69  }
70 
71  static void operator delete[](void*)
72  {
73  }
74 
75  static void operator delete(void*, Root&)
76  {
77  }
78 
79  static void operator delete[](void*, Root&)
80  {
81  }
82 
83  static void operator delete(void*, Root*)
84  {
85  }
86 
87  static void operator delete[](void*, Root*)
88  {
89  }
90 };
91 
92 }
93 }