A very fast cross-platform memory pool mechanism for C++ built using a data-oriented approach (3 to 24 times faster than regular new or delete, depending on operating system & compiler)
CPPShift::Memory::MemoryPool* CPPShift::Memory::MemoryPoolManager::create(size_t block_size) { // Create memory pool MemoryPool* mp = new MemoryPool; if (mp == NULL) throw EMemoryErrors::CANNOT_CREATE_MEMORY_POOL;
By default, the call to new MemoryPool will never return null. You should either call malloc like you do in createMemoryBlock (recommended) or catch(std::bad_alloc).
This code is wrong:
CPPShift::Memory::MemoryPool* CPPShift::Memory::MemoryPoolManager::create(size_t block_size) { // Create memory pool MemoryPool* mp = new MemoryPool; if (mp == NULL) throw EMemoryErrors::CANNOT_CREATE_MEMORY_POOL;
By default, the call tonew MemoryPool
will never return null. You should either call malloc like you do in createMemoryBlock (recommended) or catch(std::bad_alloc).