Bug 1252902 - remove ScopedFreePtr; r=Waldo
authorNathan Froyd <froydnj@mozilla.com>
Wed, 02 Mar 2016 11:44:27 -0500
changeset 323050 7cace407920cbb008f0dd2f0308293820ac058d4
parent 323049 6cbc44a2208ddc214bc9fe2f7691369ae5cf7a4a
child 323051 715c9c3fc90bc6ac92c7d8627ef8582bae5d706a
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1252902
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1252902 - remove ScopedFreePtr; r=Waldo We have UniqueFreePtr as a replacement, which at least uses more-standard machinery to do its job.
mfbt/Scoped.h
--- a/mfbt/Scoped.h
+++ b/mfbt/Scoped.h
@@ -10,52 +10,41 @@
 #define mozilla_Scoped_h
 
 /*
  * DEPRECATED: Use UniquePtr.h instead.
  *
  * Resource Acquisition Is Initialization is a programming idiom used
  * to write robust code that is able to deallocate resources properly,
  * even in presence of execution errors or exceptions that need to be
- * propagated.  The Scoped* classes defined in this header perform the
+ * propagated.  The Scoped* classes defined via the |SCOPED_TEMPLATE|
+ * and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLTE| macros perform the
  * deallocation of the resource they hold once program execution
  * reaches the end of the scope for which they have been defined.
- *
- * This header provides the following RAII classes:
+ * These macros have been used to automatically close file
+ * descriptors/file handles when reaching the end of the scope,
+ * graphics contexts, etc.
  *
- * - |ScopedFreePtr| - a container for a pointer, that automatically calls
- *   |free()| at the end of the scope;
- *
- * |ScopedDeletePtr| is removed in favor of |UniquePtr<T>|.
- * |ScopedDeleteArray| is removed in favor of |UniquePtr<T[]>|.
- *
- * The general scenario for each of the RAII classes is the following:
+ * The general scenario for RAII classes created by the above macros
+ * is the following:
  *
  * ScopedClass foo(create_value());
  * // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()|
  *        to access the value.
  * // ... In case of |return| or |throw|, |foo| is deallocated automatically.
  * // ... If |foo| needs to be returned or stored, use |foo.forget()|
  *
  * Note that the RAII classes defined in this header do _not_ perform any form
  * of reference-counting or garbage-collection. These classes have exactly two
  * behaviors:
  *
  * - if |forget()| has not been called, the resource is always deallocated at
  *   the end of the scope;
  * - if |forget()| has been called, any control on the resource is unbound
  *   and the resource is not deallocated by the class.
- *
- * Extension:
- *
- * In addition, this header provides class |Scoped| and macros |SCOPED_TEMPLATE|
- * and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE|  to simplify the definition
- * of RAII classes for other scenarios. These macros have been used to
- * automatically close file descriptors/file handles when reaching the end of
- * the scope, graphics contexts, etc.
  */
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/GuardObjects.h"
 #include "mozilla/Move.h"
 
 namespace mozilla {
@@ -214,32 +203,16 @@ struct MOZ_NON_TEMPORARY_CLASS name : pu
             MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)                        \
   {}                                                                          \
 private:                                                                      \
   explicit name(name&) = delete;                                              \
   name& operator=(name&) = delete;                                            \
 };
 
 /*
- * ScopedFreePtr is a RAII wrapper for pointers that need to be free()d.
- *
- *   struct S { ... };
- *   ScopedFreePtr<S> foo = malloc(sizeof(S));
- *   ScopedFreePtr<char> bar = strdup(str);
- */
-template<typename T>
-struct ScopedFreePtrTraits
-{
-  typedef T* type;
-  static T* empty() { return nullptr; }
-  static void release(T* aPtr) { free(aPtr); }
-};
-SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits)
-
-/*
  * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE makes it easy to create scoped
  * pointers for types with custom deleters; just overload
  * TypeSpecificDelete(T*) in the same namespace as T to call the deleter for
  * type T.
  *
  * @param name The name of the class to define.
  * @param Type A struct implementing clean-up. See the implementations
  * for more details.