16 #ifndef ARENA_POOL_HPP
17 #define ARENA_POOL_HPP
32 STATIC_CONST( HeaderSize = 2 );
34 static Uint32 computeBlockSizeInWords(Uint32 datasz) {
35 return 16 * (((datasz + 2) + 8) / 16);
42 m_first_free = ~(Uint16)0;
45 m_current_block = RNIL;
46 m_current_block_ptr = 0;
51 Uint32 m_current_block;
65 void init(Uint32 blockSize, Uint32 type_id,
const Pool_context& pc);
78 bool seize(
Ptr<void>&) { assert(
false);
return false; }
82 void * getPtr(Uint32
i);
85 void handle_invalid_release(
Ptr<void>) ATTRIBUTE_NORETURN;
97 : m_head(head), m_pool(pool) {}
99 bool seize(
Ptr<void> & ptr) {
return m_pool.seize(m_head, ptr); }
100 void release(
Ptr<void> ptr) { m_pool.release(ptr); }
101 void * getPtr(Uint32
i) {
return m_pool.getPtr(i); }
106 ArenaPool::getPtr(Uint32
i)
108 return m_allocator->m_pool.getPtr(m_record_info, i);
115 Uint32 * record_ptr =
static_cast<Uint32*
>(ptr.p);
116 Uint32 off = m_record_info.m_offset_magic;
117 Uint32 type_id = m_record_info.m_type_id;
118 Uint32 magic_val = * (record_ptr + off);
120 if (likely(magic_val == ~type_id))
122 * (record_ptr + off) = 0;
125 handle_invalid_release(ptr);