From a8fffc0cb95360918a76eea8218187c39650a405 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Jul 2012 17:29:56 -0700 Subject: [PATCH] Bug 771378 (part 0) - Add ScopedFreePtr to Utility.h. r=jwalden. --HG-- extra : rebase_source : b43cb64bb1175c4111903f5c30f533612daae841 --- js/public/Utility.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/public/Utility.h b/js/public/Utility.h index 327fce3e996..8171ec4a105 100644 --- a/js/public/Utility.h +++ b/js/public/Utility.h @@ -599,11 +599,18 @@ public: class UnwantedForeground : public Foreground { }; -template -struct ScopedDeletePtrTraits +template +struct ScopedFreePtrTraits +{ + typedef T* type; + static T* empty() { return NULL; } + static void release(T* ptr) { Foreground::free_(ptr); } +}; +SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits) + +template +struct ScopedDeletePtrTraits : public ScopedFreePtrTraits { - typedef T *type; - static T *empty() { return NULL; } static void release(T *ptr) { Foreground::delete_(ptr); } }; SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits)