diff options
Diffstat (limited to 'base/mac')
-rw-r--r-- | base/mac/scoped_mach_port.cc | 5 | ||||
-rw-r--r-- | base/mac/scoped_mach_port.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/base/mac/scoped_mach_port.cc b/base/mac/scoped_mach_port.cc index 652e3f4..9e45a85 100644 --- a/base/mac/scoped_mach_port.cc +++ b/base/mac/scoped_mach_port.cc @@ -11,9 +11,14 @@ ScopedMachPort::ScopedMachPort(mach_port_t port) : port_(port) { } ScopedMachPort::~ScopedMachPort() { + reset(); +} + +void ScopedMachPort::reset(mach_port_t port) { if (port_ != MACH_PORT_NULL) { mach_port_deallocate(mach_task_self(), port_); } + port_ = port; } } // namespace mac diff --git a/base/mac/scoped_mach_port.h b/base/mac/scoped_mach_port.h index d2aa2f7..cc2ef20 100644 --- a/base/mac/scoped_mach_port.h +++ b/base/mac/scoped_mach_port.h @@ -22,6 +22,8 @@ class BASE_EXPORT ScopedMachPort { ~ScopedMachPort(); + void reset(mach_port_t port = MACH_PORT_NULL); + operator mach_port_t() const { return port_; } |