Drizzled Public API Documentation

sql_alloc.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/memory/root.h>
00023 #include <drizzled/visibility.h>
00024 
00025 namespace drizzled {
00026 namespace memory {
00027 
00028 void* sql_alloc(size_t);
00029 void* sql_calloc(size_t);
00030 char* sql_strdup(const char*);
00031 char* sql_strdup(str_ref);
00032 void* sql_memdup(const void*, size_t);
00033 
00034 class DRIZZLED_API SqlAlloc
00035 {
00036 public:
00037   static void* operator new(size_t size)
00038   {
00039     return memory::sql_alloc(size);
00040   }
00041 
00042   static void* operator new[](size_t size)
00043   {
00044     return memory::sql_alloc(size);
00045   }
00046 
00047   static void* operator new(size_t size, Root& root)
00048   {
00049     return root.alloc(size);
00050   }
00051 
00052   static void* operator new[](size_t size, Root& root)
00053   {
00054     return root.alloc(size);
00055   }
00056 
00057   static void* operator new(size_t size, Root* root)
00058   {
00059     return root->alloc(size);
00060   }
00061 
00062   static void* operator new[](size_t size, Root* root)
00063   {
00064     return root->alloc(size);
00065   }
00066 
00067   static void operator delete(void*)
00068   {  
00069   }
00070 
00071   static void operator delete[](void*)
00072   {  
00073   }
00074 
00075   static void operator delete(void*, Root&)
00076   {  
00077   }
00078 
00079   static void operator delete[](void*, Root&)
00080   {  
00081   }
00082 
00083   static void operator delete(void*, Root*)
00084   {  
00085   }
00086 
00087   static void operator delete[](void*, Root*)
00088   {  
00089   }
00090 };
00091 
00092 }
00093 }