Bug 771378 (part 0) - Add ScopedFreePtr to Utility.h. r=jwalden.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 05 Jul 2012 17:29:56 -0700
changeset 105077 fcba8ae674df875450cf3c94a527e775949d970f
parent 105076 4a58089672882ca7f22e9866d2becf90afced9d5
child 105078 6d030947dffea35e52ba30a631e787a0d0186b86
push idunknown
push userunknown
push dateunknown
reviewersjwalden
bugs771378
milestone17.0a1
Bug 771378 (part 0) - Add ScopedFreePtr to Utility.h. r=jwalden.
js/public/Utility.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -594,21 +594,28 @@ public:
     }
 
     JS_DECLARE_DELETE_METHODS(::js_free, JS_ALWAYS_INLINE static)
 };
 
 class UnwantedForeground : public Foreground {
 };
 
-template <typename T>
-struct ScopedDeletePtrTraits
+template<typename T>
+struct ScopedFreePtrTraits
 {
-    typedef T *type;
-    static T *empty() { return NULL; }
+    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>
+{
     static void release(T *ptr) { Foreground::delete_(ptr); }
 };
 SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits)
 
 } /* namespace js */
 
 /*
  * Note lack of ; in JSRuntime below. This is intentional so "calling" this