Bug 771378 (part 0) - Add ScopedFreePtr to Utility.h. r=jwalden.

--HG--
extra : rebase_source : b43cb64bb1175c4111903f5c30f533612daae841
This commit is contained in:
Nicholas Nethercote 2012-07-05 17:29:56 -07:00
parent 62d23842f9
commit a8fffc0cb9

View File

@ -599,11 +599,18 @@ public:
class UnwantedForeground : public Foreground {
};
template <typename T>
struct ScopedDeletePtrTraits
template<typename T>
struct ScopedFreePtrTraits
{
typedef T* type;
static T* empty() { return NULL; }
static void release(T* ptr) { Foreground::free_(ptr); }
};
SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits)
template <typename T>
struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T>
{
typedef T *type;
static T *empty() { return NULL; }
static void release(T *ptr) { Foreground::delete_(ptr); }
};
SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits)