Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/Scoped.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/* DEPRECATED: Use UniquePtr.h instead. */
8
9
#ifndef mozilla_Scoped_h
10
#define mozilla_Scoped_h
11
12
/*
13
 * DEPRECATED: Use UniquePtr.h instead.
14
 *
15
 * Resource Acquisition Is Initialization is a programming idiom used
16
 * to write robust code that is able to deallocate resources properly,
17
 * even in presence of execution errors or exceptions that need to be
18
 * propagated.  The Scoped* classes defined via the |SCOPED_TEMPLATE|
19
 * and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLTE| macros perform the
20
 * deallocation of the resource they hold once program execution
21
 * reaches the end of the scope for which they have been defined.
22
 * These macros have been used to automatically close file
23
 * descriptors/file handles when reaching the end of the scope,
24
 * graphics contexts, etc.
25
 *
26
 * The general scenario for RAII classes created by the above macros
27
 * is the following:
28
 *
29
 * ScopedClass foo(create_value());
30
 * // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()|
31
 *        to access the value.
32
 * // ... In case of |return| or |throw|, |foo| is deallocated automatically.
33
 * // ... If |foo| needs to be returned or stored, use |foo.forget()|
34
 *
35
 * Note that the RAII classes defined in this header do _not_ perform any form
36
 * of reference-counting or garbage-collection. These classes have exactly two
37
 * behaviors:
38
 *
39
 * - if |forget()| has not been called, the resource is always deallocated at
40
 *   the end of the scope;
41
 * - if |forget()| has been called, any control on the resource is unbound
42
 *   and the resource is not deallocated by the class.
43
 */
44
45
#include "mozilla/Assertions.h"
46
#include "mozilla/Attributes.h"
47
#include "mozilla/GuardObjects.h"
48
#include "mozilla/Move.h"
49
50
namespace mozilla {
51
52
/*
53
 * Scoped is a helper to create RAII wrappers
54
 * Type argument |Traits| is expected to have the following structure:
55
 *
56
 *   struct Traits
57
 *   {
58
 *     // Define the type of the value stored in the wrapper
59
 *     typedef value_type type;
60
 *     // Returns the value corresponding to the uninitialized or freed state
61
 *     const static type empty();
62
 *     // Release resources corresponding to the wrapped value
63
 *     // This function is responsible for not releasing an |empty| value
64
 *     const static void release(type);
65
 *   }
66
 */
67
template<typename Traits>
68
class MOZ_NON_TEMPORARY_CLASS Scoped
69
{
70
public:
71
  typedef typename Traits::type Resource;
72
73
  explicit Scoped(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
74
    : mValue(Traits::empty())
75
42
  {
76
42
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
77
42
  }
mozilla::Scoped<ScopedCloseFileTraits>::Scoped()
Line
Count
Source
75
3
  {
76
3
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
77
3
  }
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::Scoped()
Line
Count
Source
75
39
  {
76
39
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
77
39
  }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoENetwork> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEBase> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoECodec> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEExternalMedia> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEAudioProcessing> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEVideoSync> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoERTP_RTCP> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedXFreePtrTraits<__GLXFBConfigRec*> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<PRFileDesc> >::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCloseFDTraits>::Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ipc::ScopedProcessHandleTraits>::Scoped()
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::Scoped()
78
79
  explicit Scoped(const Resource& aValue
80
                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
81
    : mValue(aValue)
82
0
  {
83
0
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
84
0
  }
Unexecuted instantiation: mozilla::Scoped<ScopedUNumberFormatTraits>::Scoped(void** const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<_cairo_surface> >::Scoped(_cairo_surface* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedXFreePtrTraits<__GLXFBConfigRec*> >::Scoped(__GLXFBConfigRec** const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCloseFileTraits>::Scoped(_IO_FILE* const&)
85
86
  /* Move constructor. */
87
  Scoped(Scoped&& aOther
88
         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
89
    : mValue(std::move(aOther.mValue))
90
  {
91
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
92
    aOther.mValue = Traits::empty();
93
  }
94
95
33
  ~Scoped() { Traits::release(mValue); }
mozilla::Scoped<ScopedCloseFileTraits>::~Scoped()
Line
Count
Source
95
3
  ~Scoped() { Traits::release(mValue); }
Unexecuted instantiation: mozilla::Scoped<ScopedUNumberFormatTraits>::~Scoped()
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::~Scoped()
Line
Count
Source
95
30
  ~Scoped() { Traits::release(mValue); }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoERTP_RTCP> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEVideoSync> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEAudioProcessing> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEExternalMedia> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoECodec> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEBase> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoENetwork> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<_cairo_surface> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedXFreePtrTraits<__GLXFBConfigRec*> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<PRFileDesc> >::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCloseFDTraits>::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ipc::ScopedProcessHandleTraits>::~Scoped()
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCloseFileTraits>::~Scoped()
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::~Scoped()
96
97
  // Constant getter
98
105
  operator const Resource&() const { return mValue; }
mozilla::Scoped<ScopedCloseFileTraits>::operator _IO_FILE* const&() const
Line
Count
Source
98
42
  operator const Resource&() const { return mValue; }
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::operator PRFileDesc* const&() const
Line
Count
Source
98
63
  operator const Resource&() const { return mValue; }
Unexecuted instantiation: mozilla::Scoped<ScopedUNumberFormatTraits>::operator void** const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoENetwork> >::operator webrtc::VoENetwork* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEBase> >::operator webrtc::VoEBase* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoECodec> >::operator webrtc::VoECodec* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEAudioProcessing> >::operator webrtc::VoEAudioProcessing* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEExternalMedia> >::operator webrtc::VoEExternalMedia* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoERTP_RTCP> >::operator webrtc::VoERTP_RTCP* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEVideoSync> >::operator webrtc::VoEVideoSync* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<_cairo_surface> >::operator _cairo_surface* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedXFreePtrTraits<__GLXFBConfigRec*> >::operator __GLXFBConfigRec** const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<PRFileDesc> >::operator PRFileDesc* const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ipc::ScopedProcessHandleTraits>::operator int const&() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCloseFileTraits>::operator _IO_FILE* const&() const
99
0
  const Resource& operator->() const { return mValue; }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoENetwork> >::operator->() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEBase> >::operator->() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoERTP_RTCP> >::operator->() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEVideoSync> >::operator->() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoECodec> >::operator->() const
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEExternalMedia> >::operator->() const
100
0
  const Resource& get() const { return mValue; }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::get() const
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::get() const
101
  // Non-constant getter.
102
9
  Resource& rwget() { return mValue; }
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::rwget()
Line
Count
Source
102
9
  Resource& rwget() { return mValue; }
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<PRFileDesc> >::rwget()
Unexecuted instantiation: mozilla::Scoped<mozilla::ipc::ScopedProcessHandleTraits>::rwget()
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::rwget()
103
104
  /*
105
   * Forget the resource.
106
   *
107
   * Once |forget| has been called, the |Scoped| is neutralized, i.e. it will
108
   * have no effect at destruction (unless it is reset to another resource by
109
   * |operator=|).
110
   *
111
   * @return The original resource.
112
   */
113
  Resource forget()
114
3
  {
115
3
    Resource tmp = mValue;
116
3
    mValue = Traits::empty();
117
3
    return tmp;
118
3
  }
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::forget()
Line
Count
Source
114
3
  {
115
3
    Resource tmp = mValue;
116
3
    mValue = Traits::empty();
117
3
    return tmp;
118
3
  }
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::forget()
119
120
  /*
121
   * Perform immediate clean-up of this |Scoped|.
122
   *
123
   * If this |Scoped| is currently empty, this method has no effect.
124
   */
125
  void dispose()
126
0
  {
127
0
    Traits::release(mValue);
128
0
    mValue = Traits::empty();
129
0
  }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::dispose()
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::dispose()
130
131
  bool operator==(const Resource& aOther) const { return mValue == aOther; }
132
133
  /*
134
   * Replace the resource with another resource.
135
   *
136
   * Calling |operator=| has the side-effect of triggering clean-up. If you do
137
   * not want to trigger clean-up, you should first invoke |forget|.
138
   *
139
   * @return this
140
   */
141
6
  Scoped& operator=(const Resource& aOther) { return reset(aOther); }
mozilla::Scoped<ScopedCloseFileTraits>::operator=(_IO_FILE* const&)
Line
Count
Source
141
3
  Scoped& operator=(const Resource& aOther) { return reset(aOther); }
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::operator=(PRFileDesc* const&)
Line
Count
Source
141
3
  Scoped& operator=(const Resource& aOther) { return reset(aOther); }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoENetwork> >::operator=(webrtc::VoENetwork* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEBase> >::operator=(webrtc::VoEBase* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoECodec> >::operator=(webrtc::VoECodec* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEExternalMedia> >::operator=(webrtc::VoEExternalMedia* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEAudioProcessing> >::operator=(webrtc::VoEAudioProcessing* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEVideoSync> >::operator=(webrtc::VoEVideoSync* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoERTP_RTCP> >::operator=(webrtc::VoERTP_RTCP* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedXFreePtrTraits<__GLXFBConfigRec*> >::operator=(__GLXFBConfigRec** const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<PRFileDesc> >::operator=(PRFileDesc* const&)
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::operator=(mozilla::(anonymous namespace)::ArrayBufferContents const&)
142
143
  Scoped& reset(const Resource& aOther)
144
6
  {
145
6
    Traits::release(mValue);
146
6
    mValue = aOther;
147
6
    return *this;
148
6
  }
mozilla::Scoped<ScopedCloseFileTraits>::reset(_IO_FILE* const&)
Line
Count
Source
144
3
  {
145
3
    Traits::release(mValue);
146
3
    mValue = aOther;
147
3
    return *this;
148
3
  }
mozilla::Scoped<mozilla::ScopedClosePRFDTraits>::reset(PRFileDesc* const&)
Line
Count
Source
144
3
  {
145
3
    Traits::release(mValue);
146
3
    mValue = aOther;
147
3
    return *this;
148
3
  }
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoENetwork> >::reset(webrtc::VoENetwork* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEBase> >::reset(webrtc::VoEBase* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoECodec> >::reset(webrtc::VoECodec* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEExternalMedia> >::reset(webrtc::VoEExternalMedia* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEAudioProcessing> >::reset(webrtc::VoEAudioProcessing* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoEVideoSync> >::reset(webrtc::VoEVideoSync* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCustomReleaseTraits0<webrtc::VoERTP_RTCP> >::reset(webrtc::VoERTP_RTCP* const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedXFreePtrTraits<__GLXFBConfigRec*> >::reset(__GLXFBConfigRec** const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::ScopedCloseFDTraits>::reset(int const&)
Unexecuted instantiation: mozilla::Scoped<mozilla::TypeSpecificScopedPointerTraits<PRFileDesc> >::reset(PRFileDesc* const&)
Unexecuted instantiation: NativeOSFileInternals.cpp:mozilla::Scoped<mozilla::(anonymous namespace)::ScopedArrayBufferContentsTraits>::reset(mozilla::(anonymous namespace)::ArrayBufferContents const&)
149
150
  /* Move assignment operator. */
151
  Scoped& operator=(Scoped&& aRhs)
152
  {
153
    MOZ_ASSERT(&aRhs != this, "self-move-assignment not allowed");
154
    this->~Scoped();
155
    new(this) Scoped(std::move(aRhs));
156
    return *this;
157
  }
158
159
private:
160
  explicit Scoped(const Scoped& aValue) = delete;
161
  Scoped& operator=(const Scoped& aValue) = delete;
162
163
private:
164
  Resource mValue;
165
  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
166
};
167
168
/*
169
 * SCOPED_TEMPLATE defines a templated class derived from Scoped
170
 * This allows to implement templates such as ScopedFreePtr.
171
 *
172
 * @param name The name of the class to define.
173
 * @param Traits A struct implementing clean-up. See the implementations
174
 * for more details.
175
 */
176
#define SCOPED_TEMPLATE(name, Traits)                                         \
177
template<typename Type>                                                       \
178
struct MOZ_NON_TEMPORARY_CLASS name : public mozilla::Scoped<Traits<Type> >   \
179
{                                                                             \
180
  typedef mozilla::Scoped<Traits<Type> > Super;                               \
181
  typedef typename Super::Resource Resource;                                  \
182
  name& operator=(Resource aRhs)                                              \
183
0
  {                                                                           \
184
0
    Super::operator=(aRhs);                                                   \
185
0
    return *this;                                                             \
186
0
  }                                                                           \
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoENetwork>::operator=(webrtc::VoENetwork*)
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEBase>::operator=(webrtc::VoEBase*)
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoECodec>::operator=(webrtc::VoECodec*)
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEExternalMedia>::operator=(webrtc::VoEExternalMedia*)
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEAudioProcessing>::operator=(webrtc::VoEAudioProcessing*)
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEVideoSync>::operator=(webrtc::VoEVideoSync*)
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoERTP_RTCP>::operator=(webrtc::VoERTP_RTCP*)
Unexecuted instantiation: mozilla::ScopedXFree<__GLXFBConfigRec*>::operator=(__GLXFBConfigRec**)
Unexecuted instantiation: mozilla::TypeSpecificScopedPointer<PRFileDesc>::operator=(PRFileDesc*)
187
  name& operator=(name&& aRhs)                                                \
188
  {                                                                           \
189
    Super::operator=(std::move(aRhs));                                             \
190
    return *this;                                                             \
191
  }                                                                           \
192
  explicit name(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)                         \
193
    : Super(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT)                   \
194
0
  {}                                                                          \
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoENetwork>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEBase>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoECodec>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEExternalMedia>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEAudioProcessing>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoEVideoSync>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedCustomReleasePtr<webrtc::VoERTP_RTCP>::ScopedCustomReleasePtr()
Unexecuted instantiation: mozilla::ScopedXFree<__GLXFBConfigRec*>::ScopedXFree()
Unexecuted instantiation: mozilla::TypeSpecificScopedPointer<PRFileDesc>::TypeSpecificScopedPointer()
195
  explicit name(Resource aRhs                                                 \
196
                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)                              \
197
    : Super(aRhs                                                              \
198
            MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)                        \
199
0
  {}                                                                          \
Unexecuted instantiation: mozilla::TypeSpecificScopedPointer<_cairo_surface>::TypeSpecificScopedPointer(_cairo_surface*)
Unexecuted instantiation: mozilla::ScopedXFree<__GLXFBConfigRec*>::ScopedXFree(__GLXFBConfigRec**)
200
  name(name&& aRhs                                                            \
201
       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)                                       \
202
    : Super(std::move(aRhs)                                                        \
203
            MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)                        \
204
  {}                                                                          \
205
private:                                                                      \
206
  explicit name(name&) = delete;                                              \
207
  name& operator=(name&) = delete;                                            \
208
};
209
210
/*
211
 * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE makes it easy to create scoped
212
 * pointers for types with custom deleters; just overload
213
 * TypeSpecificDelete(T*) in the same namespace as T to call the deleter for
214
 * type T.
215
 *
216
 * @param name The name of the class to define.
217
 * @param Type A struct implementing clean-up. See the implementations
218
 * for more details.
219
 * *param Deleter The function that is used to delete/destroy/free a
220
 *        non-null value of Type*.
221
 *
222
 * Example:
223
 *
224
 *   MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc, \
225
 *                                             PR_Close)
226
 *   ...
227
 *   {
228
 *       ScopedPRFileDesc file(PR_OpenFile(...));
229
 *       ...
230
 *   } // file is closed with PR_Close here
231
 */
232
#define MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(name, Type, Deleter) \
233
0
template <> inline void TypeSpecificDelete(Type* aValue) { Deleter(aValue); } \
Unexecuted instantiation: void mozilla::TypeSpecificDelete<_cairo_surface>(_cairo_surface*)
Unexecuted instantiation: void mozilla::TypeSpecificDelete<PRFileDesc>(PRFileDesc*)
234
typedef ::mozilla::TypeSpecificScopedPointer<Type> name;
235
236
template <typename T> void TypeSpecificDelete(T* aValue);
237
238
template <typename T>
239
struct TypeSpecificScopedPointerTraits
240
{
241
  typedef T* type;
242
0
  static type empty() { return nullptr; }
243
  static void release(type aValue)
244
0
  {
245
0
    if (aValue) {
246
0
      TypeSpecificDelete(aValue);
247
0
    }
248
0
  }
Unexecuted instantiation: mozilla::TypeSpecificScopedPointerTraits<_cairo_surface>::release(_cairo_surface*)
Unexecuted instantiation: mozilla::TypeSpecificScopedPointerTraits<PRFileDesc>::release(PRFileDesc*)
249
};
250
251
SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits)
252
253
} /* namespace mozilla */
254
255
#endif /* mozilla_Scoped_h */