Loading include/utils/NativeHandle.h +6 −3 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ namespace android { class NativeHandle: public LightRefBase<NativeHandle> { public: // Create a refcounted wrapper around a native_handle_t. // Create a refcounted wrapper around a native_handle_t, and declare // whether the wrapper owns the handle (so that it should clean up the // handle upon destruction) or not. // If handle is NULL, no NativeHandle will be created. static sp<NativeHandle> create(native_handle_t* handle); static sp<NativeHandle> create(native_handle_t* handle, bool ownsHandle); const native_handle_t* handle() const { return mHandle; Loading @@ -38,10 +40,11 @@ private: // for access to the destructor friend class LightRefBase<NativeHandle>; NativeHandle(native_handle_t* handle); NativeHandle(native_handle_t* handle, bool ownsHandle); virtual ~NativeHandle(); native_handle_t* mHandle; bool mOwnsHandle; // non-copyable NativeHandle(const NativeHandle&); Loading libutils/NativeHandle.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -19,17 +19,20 @@ namespace android { sp<NativeHandle> NativeHandle::create(native_handle_t* handle) { return handle ? new NativeHandle(handle) : NULL; sp<NativeHandle> NativeHandle::create( native_handle_t* handle, bool ownsHandle) { return handle ? new NativeHandle(handle, ownsHandle) : NULL; } NativeHandle::NativeHandle(native_handle_t* handle) : mHandle(handle) NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle) : mHandle(handle), mOwnsHandle(ownsHandle) {} NativeHandle::~NativeHandle() { if (mOwnsHandle) { native_handle_close(mHandle); native_handle_delete(mHandle); } } } // namespace android Loading
include/utils/NativeHandle.h +6 −3 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ namespace android { class NativeHandle: public LightRefBase<NativeHandle> { public: // Create a refcounted wrapper around a native_handle_t. // Create a refcounted wrapper around a native_handle_t, and declare // whether the wrapper owns the handle (so that it should clean up the // handle upon destruction) or not. // If handle is NULL, no NativeHandle will be created. static sp<NativeHandle> create(native_handle_t* handle); static sp<NativeHandle> create(native_handle_t* handle, bool ownsHandle); const native_handle_t* handle() const { return mHandle; Loading @@ -38,10 +40,11 @@ private: // for access to the destructor friend class LightRefBase<NativeHandle>; NativeHandle(native_handle_t* handle); NativeHandle(native_handle_t* handle, bool ownsHandle); virtual ~NativeHandle(); native_handle_t* mHandle; bool mOwnsHandle; // non-copyable NativeHandle(const NativeHandle&); Loading
libutils/NativeHandle.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -19,17 +19,20 @@ namespace android { sp<NativeHandle> NativeHandle::create(native_handle_t* handle) { return handle ? new NativeHandle(handle) : NULL; sp<NativeHandle> NativeHandle::create( native_handle_t* handle, bool ownsHandle) { return handle ? new NativeHandle(handle, ownsHandle) : NULL; } NativeHandle::NativeHandle(native_handle_t* handle) : mHandle(handle) NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle) : mHandle(handle), mOwnsHandle(ownsHandle) {} NativeHandle::~NativeHandle() { if (mOwnsHandle) { native_handle_close(mHandle); native_handle_delete(mHandle); } } } // namespace android