A
Anonymous
I am writing memory allocation class policies for a template class.
I have defined one allocated like this:
template <class T>
struct myMallocAllocator
{
static T* Allocate()
{
void * ptr = calloc(1, sizeof(T));
if (ptr)
return new(ptr) T ;
else
return 0 ;
}
static void DeAllocate(T *ptr)
{
if(ptr);
ptr->~T() ;
}
};
Am i deallocating correctly?
I have defined one allocated like this:
template <class T>
struct myMallocAllocator
{
static T* Allocate()
{
void * ptr = calloc(1, sizeof(T));
if (ptr)
return new(ptr) T ;
else
return 0 ;
}
static void DeAllocate(T *ptr)
{
if(ptr);
ptr->~T() ;
}
};
Am i deallocating correctly?