Здравствуйте, SergH, Вы писали:
>>..
Да, небольшое пояснение всё-таки нужно. Стандартный аллокатор это new + delete, быстрый аллокатор выглядит так:
#ifdef USE_FAST_ALLOCATOR
namespace allocator
{
const int blockSize = 1024 * 1024 * 10;
inline void* malloc(size_t count)
{
#ifdef _WIN32
// VC standard
static __declspec(thread) char* begin = 0;
static __declspec(thread) char* end = 0;
#else
// GCC standard
static __thread char* begin = 0;
static __thread char* end = 0;
#endif
if ((count & 0x0f) != 0)
{
// 16-byte address alignment
count &= ~0x0f;
count += 0x010;
}
if (end - begin < (int)count)
{
// need allocate new block
begin = (char*)::malloc(blockSize);
end = begin + blockSize;
}
char* tmp = begin;
begin += count;
return tmp;
}
inline void free(const void* po)
{
}
}
inline void* operator new (size_t count) throw (std::bad_alloc)
{
return allocator::malloc(count);
}
inline void operator delete (void* p) throw()
{
allocator::free(p);
}
#endif