Sounds like you just want to override global new?
void* operator new (size_t size)
{
void *p=my_pool_alloc(size);
if (p==0) // did malloc succeed?
throw std::bad_alloc(); // ANSI/ISO compliant behavior
return p;
}
void* operator new (size_t size)
{
void *p=my_pool_alloc(size);
if (p==0) // did malloc succeed?
throw std::bad_alloc(); // ANSI/ISO compliant behavior
return p;
}
To copy to clipboard, switch view to plain text mode
I'm not sure plugins would go to this new though, I imagine operator overrides are resolved at compile time?
I definitely agree that thousands of small new calls are very bad - has to bug the OS every time for memory, that's awful/adds up.
But of course, you'll probably run into all sorts of trouble if you ever need to dynamically increase your pool size. I personally would prefer more restricted overrides of new (class-limited) rather than global. Then again, your current needs are probably different.
Contest deadline? :P
Bookmarks