*** shared_count.hpp.~1.31.~ Sun Jan 19 10:14:15 2003 --- shared_count.hpp Wed Jan 29 17:28:11 2003 *************** *** 37,45 **** --- 37,104 ---- # pragma warn -8027 // Functions containing try are not expanded inline #endif + # include + # include + # include + namespace boost { + namespace aux_ + { + // # include + + template + union freeblock + { + typename boost::type_with_alignment::type aligner; + char bytes[sz]; + freeblock *next; + }; + + template + struct allocator_impl + { + typedef freeblock block; + + static std::deque store; + static block* free; + + static inline void* alloc() + { + block* x = free; + if (x) + { + free = x->next; + return x; + } + else + { + store.resize(store.size() + 1); + return &store.back(); + } + } + + static inline void dealloc(void* p_) + { + block* p = static_cast(p_); + p->next = free; + free = p; + } + }; + + + template + std::deque > allocator_impl::store; + + template + freeblock* allocator_impl::free = 0; + + template + struct quick_allocator : allocator_impl::value> + { + }; + } // Debug hooks #if defined(BOOST_ENABLE_SP_DEBUG_HOOKS) *************** *** 272,277 **** --- 331,346 ---- void operator delete(void * p) { std::allocator().deallocate(static_cast(p), 1); + } + #else + void * operator new(std::size_t) + { + return aux_::quick_allocator::alloc(); + } + + void operator delete(void * p) + { + aux_::quick_allocator::dealloc(p); } #endif