Move the free_list management into a separate class for reuse.

* src/misc/freelist.hh, src/misc/freelist.cc: New files.
* src/misc/Makefile.am (misc_HEADERS, libmisc_la_SOURCES): Add them.
* src/misc/bddalloc.hh (bdd_allocator): Inherit from free_list and
make dump_free_list visible.
* src/misc/bddalloc.cc (bdd_allocator::allocate_variables): Move
all the code into free_list::register_n() and
bdd_allocator::extend(), and call the former.
(bdd_allocator::release_variables): Move all the code into
free_list::release_n() and call it.
(bdd_allocator::extend): New method.
* src/tgba/bdddict.cc (bdd_dict::dump): Call dump_free_list;
This commit is contained in:
Alexandre Duret-Lutz 2004-03-18 15:43:10 +00:00
parent b84e6a6440
commit cf6602a3be
7 changed files with 228 additions and 86 deletions

View file

@ -22,14 +22,14 @@
#ifndef SPOT_MISC_BDDALLOC_HH
# define SPOT_MISC_BDDALLOC_HH
#include "freelist.hh"
#include <list>
#include <utility>
namespace spot
{
/// Manage ranges of variables.
class bdd_allocator
class bdd_allocator: private free_list
{
public:
/// Default constructor.
@ -40,16 +40,16 @@ namespace spot
int allocate_variables(int n);
/// Release \a n BDD variables starting at \a base.
void release_variables(int base, int n);
using free_list::dump_free_list;
protected:
static bool initialized; ///< Whether the BDD library has been initialized.
static int varnum; ///< number of variables in use in the BDD library.
int lvarnum; ///< number of variables in use in this allocator.
typedef std::pair<int, int> pos_lenght_pair;
typedef std::list<pos_lenght_pair> free_list_type;
free_list_type free_list; ///< Tracks unused BDD variables.
private:
/// Require more variables.
void extvarnum(int more);
virtual int extend(int n);
};
}