Add move constructor/assignment operator to hidl_memory
Bug: 34093434
Test: hidl_test passes
Change-Id: I6bb7e2e3c914040daa8d72d9a86a5a3d3f8338e5
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index d22c257..92a0e96 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -234,7 +234,23 @@
return *this;
}
- // TODO move constructor/move assignment
+ // move constructor
+ hidl_memory(hidl_memory&& other) {
+ *this = std::move(other);
+ }
+
+ // move assignment
+ hidl_memory &operator=(hidl_memory &&other) {
+ if (this != &other) {
+ mHandle = std::move(other.mHandle);
+ mSize = other.mSize;
+ mName = std::move(other.mName);
+ other.mSize = 0;
+ }
+
+ return *this;
+ }
+
~hidl_memory() {
}