Better constructors for hidl_memory.
Allow hidl_memory to take ownership of a handle. A hidl_handle
object can now be moved into a hidl_memory object. This way the
lifetime of the handle corresponds to the lifetime of the
hidl_memory object.
Test: w/ mapMemory + drm
Bug: 34234561
Change-Id: I8cd6bbc35165c5a595538c0c17306549b01ba8a2
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 78e0867..2be97c2 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -208,6 +208,13 @@
}
/**
+ * Creates a hidl_memory object whose handle has the same lifetime
+ * as the handle moved into it.
+ */
+ hidl_memory(const hidl_string& name, hidl_handle&& handle, size_t size)
+ : mHandle(std::move(handle)), mSize(size), mName(name) {}
+
+ /**
* Creates a hidl_memory object, but doesn't take ownership of
* the passed in native_handle_t; callers are responsible for
* making sure the handle remains valid while this object is