2001-05-23 15:26:42 +02:00
|
|
|
#ifndef INCLUDE_FB_BLK
|
|
|
|
#define INCLUDE_FB_BLK
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#include "../common/memory/memory_pool.h"
|
|
|
|
//#include <vector>
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
struct blk
|
|
|
|
{
|
|
|
|
};
|
|
|
|
typedef blk* BLK;
|
|
|
|
|
|
|
|
|
|
|
|
//typedef PtrWrapper<BLK> BlkPtr;
|
|
|
|
typedef blk* BlkPtr;
|
|
|
|
|
|
|
|
template<SSHORT TYPE = 0>
|
|
|
|
class pool_alloc : public blk
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void* operator new(size_t s, MemoryPool& p )
|
|
|
|
{ return p.allocate(s, TYPE); }
|
|
|
|
void operator delete(void* mem, MemoryPool& p)
|
2002-04-04 07:38:26 +02:00
|
|
|
{ if (mem) p.deallocate(mem); }
|
2001-12-24 03:51:06 +01:00
|
|
|
|
|
|
|
void* operator new[](size_t s, MemoryPool& p)
|
|
|
|
{ return p.allocate(s, TYPE); }
|
|
|
|
void operator delete[](void* mem, MemoryPool& p)
|
2002-04-04 07:38:26 +02:00
|
|
|
{ if (mem) p.deallocate(mem); }
|
2001-12-24 03:51:06 +01:00
|
|
|
|
2002-04-04 07:38:26 +02:00
|
|
|
void operator delete(void* mem) { if (mem) MemoryPool::deallocate(mem); }
|
|
|
|
void operator delete[](void* mem) { if (mem) MemoryPool::deallocate(mem); }
|
2001-12-24 03:51:06 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
/* These operators are off-limits */
|
|
|
|
void* operator new(size_t s) { return 0; }
|
|
|
|
void* operator new[](size_t s) { return 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class RPT, SSHORT TYPE = 0>
|
|
|
|
class pool_alloc_rpt : public blk
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void* operator new(size_t s, MemoryPool& p, int rpt)
|
|
|
|
{ return p.allocate(s + sizeof(RPT)*rpt, TYPE); }
|
|
|
|
void operator delete(void* mem, MemoryPool& p,int rpt)
|
2002-04-04 07:38:26 +02:00
|
|
|
{ if (mem) p.deallocate(mem); }
|
|
|
|
void operator delete(void* mem) { if (mem) MemoryPool::deallocate(mem); }
|
2001-12-24 03:51:06 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// These operations are not supported on static repeat-base objects
|
|
|
|
void* operator new[](size_t s, MemoryPool& p)
|
|
|
|
{ return 0; }
|
|
|
|
void operator delete[](void* mem, MemoryPool& p)
|
|
|
|
{ }
|
|
|
|
void operator delete[](void* mem) { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* These operators are off-limits */
|
|
|
|
void* operator new(size_t s) { return 0; }
|
|
|
|
void* operator new[](size_t s) { return 0; }
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
/* template<class BASE, class RPT, UCHAR TYPE>
|
|
|
|
class vector_rpt : public BASE
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2001-12-24 03:51:06 +01:00
|
|
|
private:
|
|
|
|
MemoryPool::allocator<RPT> rptAllocator;
|
|
|
|
vector_rpt(int size, MemoryPool& pool)
|
|
|
|
: rptAllocator(pool, TYPE), rpt(size, rptAllocator) {}
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
public:
|
|
|
|
std::vector<RPT> rpt;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
static vector_rpt<BASE,RPT,TYPE>* allocate(int size, MemoryPool& p)
|
|
|
|
{ return new(p) vector_rpt<BASE,RPT,TYPE>(size,p); }
|
|
|
|
}; */
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#endif /* INCLUDE_FB_BLK */
|