Disk ARchive
2.4.2
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 // $Id: special_alloc.hpp,v 1.11 2011/01/09 17:25:58 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00035 00036 #ifndef SPECIAL_ALLOC_HPP 00037 #define SPECIAL_ALLOC_HPP 00038 00039 #include "../my_config.h" 00040 00041 #ifdef LIBDAR_SPECIAL_ALLOC 00042 00043 extern "C" 00044 { 00045 #if HAVE_STDDEF_H 00046 #include <stddef.h> 00047 #else 00048 #if HAVE_STDLIB_H 00049 #include <stdlib.h> 00050 #endif 00051 #endif 00052 } // end extern "C" 00053 00056 00057 #define USE_SPECIAL_ALLOC(BASE_TYPE) \ 00058 void *operator new(size_t taille) { return special_alloc_new(taille); }; \ 00059 void *operator new(size_t taille, BASE_TYPE * & place) { return (void *) place; }; \ 00060 void *operator new(size_t taille, void * & place) { return place; }; \ 00061 void operator delete(void *ptr) { special_alloc_delete(ptr); } 00062 00063 namespace libdar 00064 { 00065 // this following call is to be used in a 00066 // multi-thread environment and is called from 00067 // libdar global initialization function 00068 // this makes the libdar thread-safe if POSIX mutex 00069 // are available 00070 extern void special_alloc_init_for_thread_safe(); 00071 00072 extern void *special_alloc_new(size_t taille); 00073 extern void special_alloc_delete(void *ptr); 00074 00075 } // end of namespace 00076 00077 #endif 00078 00080 00081 #endif 00082