+ use in-place ::new/::delete

This commit is contained in:
Artem Pavlenko 2012-03-23 09:30:35 +00:00
parent f0b6fffcc9
commit 2f5e7f8464

View file

@ -35,10 +35,10 @@ namespace agg
//------------------------------------------------------------pod_allocator
template<class T> struct pod_allocator
{
static T* allocate(unsigned num) { return new T [num]; }
static void deallocate(T* ptr, unsigned) { delete [] ptr; }
static T* allocate(unsigned num) { return static_cast<T*>(::operator new(sizeof(T)*num));}
static void deallocate(T* ptr, unsigned) { ::operator delete(ptr) ;}
};
// Single object allocator. It's also can be replaced with your custom
// allocator. The difference is that it can only allocate a single
// object and the constructor and destructor must be called.