eXpl0it3r, I'll answer your question about why I want to use my own pool shortly. For now, could you answer another question for me?
I think my question number 3 was a bit pointless because obviously I would put checks in my Editor to make sure the user doesn't load in 2000x2000 sized Images.
So, what happens when Image requests too much memory and the request fails? On my side (in the pool), it just returns null, or throws an exception (for the placement version of new). But how does sf::Image, for example, deal with this? I've heard SFML doesn't use exceptions. LoadFromFile returns false, but what happens internally if new returns null (for a request bigger than 2 mib)?
This is what the overloaded new and delete looks like:
#include <new>
#include "../Pool/Pool.hpp"
void* operator new(std::size_t s)
{
return memory::pool::allocate_b_4096(s, 0, 0);
}
void* operator new[](std::size_t s)
{
return memory::pool::allocate_b_4096(s, 0, 0);
}
void* operator new(std::size_t s, const std::nothrow_t&)
{
return memory::pool::allocate_b_4096_noexcept(s, 0, 0);
}
void* operator new[](std::size_t s, const std::nothrow_t&)
{
return memory::pool::allocate_b_4096_noexcept(s, 0, 0);
}
void operator delete(void* p) noexcept
{
if (p) { memory::pool::free(p); }
}
void operator delete[](void* p) noexcept
{
if (p) { memory::pool::free(p); }
}