summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host/macosx/cfcpp/CFCReleaser.h')
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCReleaser.h18
1 files changed, 0 insertions, 18 deletions
diff --git a/lldb/source/Host/macosx/cfcpp/CFCReleaser.h b/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
index 816dba8813b..8a29f398021 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
@@ -15,7 +15,6 @@
#include <assert.h>
-//----------------------------------------------------------------------
// Templatized CF helper class that can own any CF pointer and will
// call CFRelease() on any valid pointer it owns unless that pointer is
// explicitly released using the release() member function. This class
@@ -24,42 +23,33 @@
// CFCReleaser<T>::release() function won't actually CFRelease any owned
// pointer, it is designed to relinquish ownership of the pointer just
// like std:auto_ptr<T>::release() does.
-//----------------------------------------------------------------------
template <class T> class CFCReleaser {
public:
- //----------------------------------------------------------
// Constructor that takes a pointer to a CF object that is
// to be released when this object goes out of scope
- //----------------------------------------------------------
CFCReleaser(T ptr = NULL) : _ptr(ptr) {}
- //----------------------------------------------------------
// Copy constructor
//
// Note that copying a CFCReleaser will not transfer
// ownership of the contained pointer, but it will bump its
// reference count. This is where this class differs from
// std::auto_ptr.
- //----------------------------------------------------------
CFCReleaser(const CFCReleaser &rhs) : _ptr(rhs.get()) {
if (get())
::CFRetain(get());
}
- //----------------------------------------------------------
// The destructor will release the pointer that it contains
// if it has a valid pointer.
- //----------------------------------------------------------
virtual ~CFCReleaser() { reset(); }
- //----------------------------------------------------------
// Assignment operator.
//
// Note that assigning one CFCReleaser to another will
// not transfer ownership of the contained pointer, but it
// will bump its reference count. This is where this class
// differs from std::auto_ptr.
- //----------------------------------------------------------
CFCReleaser &operator=(const CFCReleaser<T> &rhs) {
if (this != &rhs) {
// Replace our owned pointer with the new one
@@ -71,7 +61,6 @@ public:
return *this;
}
- //----------------------------------------------------------
// Get the address of the contained type in case it needs
// to be passed to a function that will fill in a pointer
// value. The function currently will assert if _ptr is not
@@ -83,36 +72,29 @@ public:
// sure any owned objects has CFRelease called on it.
// I had to add the "enforce_null" bool here because some
// API's require the pointer address even though they don't change it.
- //----------------------------------------------------------
T *ptr_address(bool enforce_null = true) {
if (enforce_null)
assert(_ptr == NULL);
return &_ptr;
}
- //----------------------------------------------------------
// Access the pointer itself
- //----------------------------------------------------------
T get() { return _ptr; }
const T get() const { return _ptr; }
- //----------------------------------------------------------
// Set a new value for the pointer and CFRelease our old
// value if we had a valid one.
- //----------------------------------------------------------
void reset(T ptr = NULL) {
if ((_ptr != NULL) && (ptr != _ptr))
::CFRelease(_ptr);
_ptr = ptr;
}
- //----------------------------------------------------------
// Release ownership without calling CFRelease. This class
// is designed to mimic std::auto_ptr<T>, so the release
// method releases ownership of the contained pointer
// and does NOT call CFRelease.
- //----------------------------------------------------------
T release() {
T tmp = _ptr;
_ptr = NULL;
OpenPOWER on IntegriCloud