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 102726 fcba8ae674df875450cf3c94a527e775949d970f
parent 102725 4a58089672882ca7f22e9866d2becf90afced9d5
child 102727 6d030947dffea35e52ba30a631e787a0d0186b86
push id1989
push userakeybl@mozilla.com
push dateTue, 28 Aug 2012 00:20:43 +0000
treeherdermozilla-aurora@a8e95ae10ea7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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