<Off fixed allocator. >= (U->)
// A software-table fixed-size allocator.
//
class off_FixedAllocator: public off_SwAllocator {
public:
// Allows declarations of uninitialized fixed allocators.
off_FixedAllocator(void){;}
//Creates a sw. fixed allocator.
off_FixedAllocator(off_Exhausted *r, const off_Indexable *i,
void *first, natural_t len ) :
off_SwAllocator(r,i,first,len)
{ ; }
};
Definesoff_FixedAllocator(links are to index).
<Off fixed allocator dependencies. >= (U->) #include <klib/SwAllocator.h> // for off_SwAllocator
A fixed allocator can be instantiated, so we provide a type-safe interface for it.
<Off type safe fixed allocator. >= (U->)
// A software-table fixed-size allocator.
//
template <class T>
class off_TFixedAllocator : private off_FixedAllocator {
public:
// Allows declarations of uninitialized fixed allocators.
off_TFixedAllocator(void) : off_FixedAllocator() {;}
//Creates a sw. fixed allocator.
off_TFixedAllocator(off_Exhausted *r, const off_Indexable *i,
T *first, natural_t len ) :
off_FixedAllocator(r, i, (void *)first, len )
{ ; }
// Allocate (deallocate) units.
// Return NULL when allocation failed.
T *allocate(boolean_t use_revocation=FALSE ) {
return (T*)off_FixedAllocator::allocate(use_revocation);
}
T *allocate(natural_t at, boolean_t use_revocation=FALSE) {
return (T*) off_FixedAllocator::allocate(at,use_revocation);
}
void deallocate(T *p) { off_FixedAllocator::deallocate((void*)p); }
off_FixedAllocator::is_free;
T *operator +(natural_t at) {
return (T*)(this->off_KernAllocator::operator+(at));
}
natural_t pos(T *p) { return off_KernAllocator::pos((void*)p); }
off_BKAllocator::get_nfree;
off_BKAllocator::get_nalloc;
off_BKAllocator::get_maxalloc;
off_BKAllocator::get_num_allocrq;
off_BKAllocator::get_num_freerq;
off_BKAllocator::get_length;
<Other public methods of off_TFixedAllocator. >
};
Definesoff_TFixedAllocator(links are to index).
To allow initialization of pre-allocated TFixedAllocators an operator
new is provided.
<Other public methods of off_TFixedAllocator. >= (<-U) [D->]
void * operator new(size_t s, void *p) { (void)s; return p; }