![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 00025 00026 00027 00028 #ifndef MEM_SIZED_HPP 00029 #define MEM_SIZED_HPP 00030 00031 #include "../my_config.h" 00032 #include "mem_allocator.hpp" 00033 #include "mem_cluster.hpp" 00034 #include <list> 00035 00036 namespace libdar 00037 { 00038 00039 00042 00043 class mem_sized : public mem_manager 00044 { 00045 public: 00046 mem_sized(U_I x_block_size); 00047 mem_sized(const mem_sized & ref) { throw SRC_BUG; }; 00048 const mem_sized & operator = (const mem_sized & ref) { throw SRC_BUG; }; 00049 ~mem_sized(); 00050 00056 void *alloc(mem_allocator * & ptr); 00057 00059 bool is_empty() const; 00060 00062 std::string dump() const; 00063 00064 #ifdef LIBDAR_DEBUG_MEMORY 00065 00067 U_I max_percent_full() const; 00068 #endif 00069 00071 virtual void push_to_release_list(mem_allocator *ref); 00072 00073 private: 00074 static const U_I average_table_size = 10240; 00075 00076 U_I table_size_64; //< size for clusters 00077 std::list<mem_cluster *> clusters; //< the list of owned mem_cluster objects 00078 std::list<mem_cluster *>::iterator next_free_in_table; //< points to an mem_cluster that is known to have free slots 00079 mem_cluster *pending_release; //< a totally free cluster that can be recycled if all others are full and a new block is requested or freed if another mem_cluster becomes also totally free 00080 #ifdef LIBDAR_DEBUG_MEMORY 00081 U_I sum_percent; //< summ of all max percent usage obtained before deleting a mem_cluster object (used for statistical purposes) 00082 U_I num_cluster; //< number of cluster which sum_percent has been collected from (sum_percent/num_cluster gives the average load of mem_clusters) 00083 #endif 00084 }; 00085 00087 00088 } // end of namespace 00089 00090 #endif