unsigned block_count = capacity/BLOCK_SIZE;
for(unsigned i=0; i<block_count; ++i)
- delete[] blocks[i];
- delete[] reinterpret_cast<char *>(blocks);
+ ::operator delete(blocks[i]);
+ ::operator delete(blocks);
}
void *PoolBase::prepare_allocate()
void PoolBase::add_block()
{
unsigned block_count = capacity/BLOCK_SIZE;
- char *new_mem = new alignas(char *) char[(block_count+1)*(sizeof(char *)+BLOCK_SIZE*sizeof(uint32_t))];
+ size_t meta_size = (block_count+1)*(sizeof(char *)+BLOCK_SIZE*sizeof(uint32_t));
+ char *new_mem = static_cast<char *>(::operator new(meta_size, static_cast<align_val_t>(alignof(char *))));
char **new_blocks = reinterpret_cast<char **>(new_mem);
uint32_t *new_free = reinterpret_cast<uint32_t *>(new_mem+(block_count+1)*sizeof(char *));
copy(blocks, blocks+block_count, new_blocks);
copy(free_list, free_list+capacity, new_free);
- char *block = new alignas(BLOCK_ALIGNMENT) char[BLOCK_SIZE*object_size+BLOCK_SIZE/8];
+ size_t storage_size = BLOCK_SIZE*object_size+BLOCK_SIZE/8;
+ char *block = static_cast<char *>(::operator new(storage_size, static_cast<align_val_t>(BLOCK_ALIGNMENT)));
new_blocks[block_count] = block;
FlagType *flags = reinterpret_cast<FlagType *>(block+BLOCK_SIZE*object_size);
for(unsigned i=0; i<BLOCK_SIZE; ++i)
for(unsigned i=0; i<BLOCK_SIZE/FLAG_BITS; ++i)
flags[i] = 0;
- delete[] reinterpret_cast<char *>(blocks);
+ ::operator delete(blocks);
blocks = new_blocks;
free_list = new_free;
capacity += BLOCK_SIZE;