ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Minisat::RegionAllocator< T > Class Template Reference

#include <Alloc.h>

Public Types

enum  { Ref_Undef = UINT32_MAX }
 
enum  { Unit_Size = sizeof(uint32_t) }
 
typedef uint32_t Ref
 

Public Member Functions

 RegionAllocator (uint32_t start_cap=1024 *1024)
 
 ~RegionAllocator ()
 
uint32_t size () const
 
uint32_t wasted () const
 
Ref alloc (int size)
 
void _free (int size)
 
T & operator[] (Ref r)
 
const T & operator[] (Ref r) const
 
T * lea (Ref r)
 
const T * lea (Ref r) const
 
Ref ael (const T *t)
 
void moveTo (RegionAllocator &to)
 

Detailed Description

template<class T>
class Minisat::RegionAllocator< T >

Definition at line 35 of file Alloc.h.

Member Typedef Documentation

◆ Ref

template<class T>
typedef uint32_t Minisat::RegionAllocator< T >::Ref

Definition at line 46 of file Alloc.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T>
anonymous enum
Enumerator
Ref_Undef 

Definition at line 47 of file Alloc.h.

◆ anonymous enum

template<class T>
anonymous enum
Enumerator
Unit_Size 

Definition at line 48 of file Alloc.h.

48{ Unit_Size = sizeof(uint32_t) };

Constructor & Destructor Documentation

◆ RegionAllocator()

template<class T>
Minisat::RegionAllocator< T >::RegionAllocator ( uint32_t start_cap = 1024*1024)
inlineexplicit

Definition at line 50 of file Alloc.h.

50: memory(NULL), sz(0), cap(0), wasted_(0){ capacity(start_cap); }

◆ ~RegionAllocator()

template<class T>
Minisat::RegionAllocator< T >::~RegionAllocator ( )
inline

Definition at line 51 of file Alloc.h.

52 {
53 if (memory != NULL)
54 ::free(memory);
55 }
VOID_HACK free()

Member Function Documentation

◆ _free()

template<class T>
void Minisat::RegionAllocator< T >::_free ( int size)
inline

Definition at line 62 of file Alloc.h.

62{ wasted_ += size; }
uint32_t size() const
Definition Alloc.h:58
Here is the caller graph for this function:

◆ ael()

template<class T>
Ref Minisat::RegionAllocator< T >::ael ( const T * t)
inline

Definition at line 70 of file Alloc.h.

70 { assert((void*)t >= (void*)&memory[0] && (void*)t < (void*)&memory[sz-1]);
71 return (Ref)(t - &memory[0]); }
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ alloc()

template<class T>
RegionAllocator< T >::Ref Minisat::RegionAllocator< T >::alloc ( int size)

Definition at line 117 of file Alloc.h.

118{
119 // printf("ALLOC called (this = %p, size = %d)\n", this, size); fflush(stdout);
120 assert(size > 0);
121 capacity(sz + size);
122
123 uint32_t prev_sz = sz;
124 sz += size;
125
126 // Handle overflow:
127 if (sz < prev_sz)
128#ifdef __wasm
129 abort();
130#else
131 throw OutOfMemoryException();
132#endif
133
134 return prev_sz;
135}
VOID_HACK abort()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lea() [1/2]

template<class T>
T * Minisat::RegionAllocator< T >::lea ( Ref r)
inline

Definition at line 68 of file Alloc.h.

68{ assert(r >= 0 && r < sz); return &memory[r]; }
Here is the caller graph for this function:

◆ lea() [2/2]

template<class T>
const T * Minisat::RegionAllocator< T >::lea ( Ref r) const
inline

Definition at line 69 of file Alloc.h.

69{ assert(r >= 0 && r < sz); return &memory[r]; }

◆ moveTo()

template<class T>
void Minisat::RegionAllocator< T >::moveTo ( RegionAllocator< T > & to)
inline

Definition at line 73 of file Alloc.h.

73 {
74 if (to.memory != NULL) ::free(to.memory);
75 to.memory = memory;
76 to.sz = sz;
77 to.cap = cap;
78 to.wasted_ = wasted_;
79
80 memory = NULL;
81 sz = cap = wasted_ = 0;
82 }
Here is the caller graph for this function:

◆ operator[]() [1/2]

template<class T>
T & Minisat::RegionAllocator< T >::operator[] ( Ref r)
inline

Definition at line 65 of file Alloc.h.

65{ assert(r >= 0 && r < sz); return memory[r]; }
Here is the caller graph for this function:

◆ operator[]() [2/2]

template<class T>
const T & Minisat::RegionAllocator< T >::operator[] ( Ref r) const
inline

Definition at line 66 of file Alloc.h.

66{ assert(r >= 0 && r < sz); return memory[r]; }

◆ size()

template<class T>
uint32_t Minisat::RegionAllocator< T >::size ( ) const
inline

Definition at line 58 of file Alloc.h.

58{ return sz; }
Here is the caller graph for this function:

◆ wasted()

template<class T>
uint32_t Minisat::RegionAllocator< T >::wasted ( ) const
inline

Definition at line 59 of file Alloc.h.

59{ return wasted_; }

The documentation for this class was generated from the following file: