summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWonsik Kim2014-03-20 01:42:03 -0500
committerWonsik Kim2014-03-23 21:40:36 -0500
commitc4cc584bbd031b94c37912d8c5e340b24ff31b57 (patch)
treea70d9c987788b1503ecfe2fd5936d07d681a59cc /libutils/NativeHandle.cpp
parenta2910877a6781f57a7ef3eea7343fa46bc3e1bd0 (diff)
downloadplatform-system-core-c4cc584bbd031b94c37912d8c5e340b24ff31b57.tar.gz
platform-system-core-c4cc584bbd031b94c37912d8c5e340b24ff31b57.tar.xz
platform-system-core-c4cc584bbd031b94c37912d8c5e340b24ff31b57.zip
Clarify ownership for NativeHandle::mHandle
Change-Id: I0835278df1aa78f10d5493d7ef2c9e4a15c0fee9
Diffstat (limited to 'libutils/NativeHandle.cpp')
-rw-r--r--libutils/NativeHandle.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/libutils/NativeHandle.cpp b/libutils/NativeHandle.cpp
index 6632851af..e4daca7ff 100644
--- a/libutils/NativeHandle.cpp
+++ b/libutils/NativeHandle.cpp
@@ -19,17 +19,20 @@
19 19
20namespace android { 20namespace android {
21 21
22sp<NativeHandle> NativeHandle::create(native_handle_t* handle) { 22sp<NativeHandle> NativeHandle::create(
23 return handle ? new NativeHandle(handle) : NULL; 23 native_handle_t* handle, bool ownsHandle) {
24 return handle ? new NativeHandle(handle, ownsHandle) : NULL;
24} 25}
25 26
26NativeHandle::NativeHandle(native_handle_t* handle) 27NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle)
27: mHandle(handle) 28: mHandle(handle), mOwnsHandle(ownsHandle)
28{} 29{}
29 30
30NativeHandle::~NativeHandle() { 31NativeHandle::~NativeHandle() {
31 native_handle_close(mHandle); 32 if (mOwnsHandle) {
32 native_handle_delete(mHandle); 33 native_handle_close(mHandle);
34 native_handle_delete(mHandle);
35 }
33} 36}
34 37
35} // namespace android 38} // namespace android