|
Disk ARchive
2.4.12
|
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 00032 00033 #ifndef SPECIAL_ALLOC_HPP 00034 #define SPECIAL_ALLOC_HPP 00035 00036 #include "../my_config.h" 00037 #include <iostream> 00038 #include <new> 00039 00040 #ifdef LIBDAR_SPECIAL_ALLOC 00041 00042 extern "C" 00043 { 00044 #if HAVE_STDDEF_H 00045 #include <stddef.h> 00046 #else 00047 #if HAVE_STDLIB_H 00048 #include <stdlib.h> 00049 #endif 00050 #endif 00051 } // end extern "C" 00052 00055 00056 #define USE_SPECIAL_ALLOC(BASE_TYPE) \ 00057 void *operator new(size_t taille) { return special_alloc_new(taille); }; \ 00058 void *operator new(size_t taille, const std::nothrow_t& nothrow_constant) { 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) throw() { special_alloc_delete(ptr); } \ 00062 void operator delete(void* ptr, const std::nothrow_t& nothrow_constant) throw() { special_alloc_delete(ptr); } 00063 00064 namespace libdar 00065 { 00066 // this following call is to be used in a 00067 // multi-thread environment and is called from 00068 // libdar global initialization function 00069 // this makes libdar thread-safe if POSIX mutex 00070 // are available 00071 extern void special_alloc_init_for_thread_safe(); 00072 00073 extern void *special_alloc_new(size_t taille); 00074 extern void special_alloc_delete(void *ptr); 00075 00076 // this should be called for sanity and control purposes just before ending the program, 00077 // it will report any block still not yet released 00078 extern void special_alloc_garbage_collect(std::ostream & output); 00079 00080 00081 } // end of namespace 00082 00083 #endif 00084 00086 00087 #endif 00088
1.7.6.1