summaryrefslogtreecommitdiffstats
path: root/libutils/FileMap.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-09-22 18:42:19 -0700
committerAdam Lesinski <adamlesinski@google.com>2015-10-01 12:47:49 -0700
commit6f8885bc143460d77f300a981169e0487ff923c1 (patch)
tree5d12dce856d59d764bab7eeefacce9a2e8d746ea /libutils/FileMap.cpp
parent17cd2c49c9234758b76cb7e43d0bd12496ef31fb (diff)
downloadsystem_core-6f8885bc143460d77f300a981169e0487ff923c1.tar.gz
system_core-6f8885bc143460d77f300a981169e0487ff923c1.tar.bz2
system_core-6f8885bc143460d77f300a981169e0487ff923c1.zip
Implement C++11 move semantics for android::FileMap
FileMaps should be movable, thereby not requiring them to be only used with a unique_ptr as they currently are. Change-Id: I0fb8013bf398a2ced5420d85ba888c2a7fc5a496
Diffstat (limited to 'libutils/FileMap.cpp')
-rw-r--r--libutils/FileMap.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/libutils/FileMap.cpp b/libutils/FileMap.cpp
index 91e45d873..4f4b8895a 100644
--- a/libutils/FileMap.cpp
+++ b/libutils/FileMap.cpp
@@ -53,6 +53,43 @@ FileMap::FileMap(void)
{
}
+// Move Constructor.
+FileMap::FileMap(FileMap&& other)
+ : mFileName(other.mFileName), mBasePtr(other.mBasePtr), mBaseLength(other.mBaseLength),
+ mDataOffset(other.mDataOffset), mDataPtr(other.mDataPtr), mDataLength(other.mDataLength)
+#if defined(__MINGW32__)
+ , mFileHandle(other.mFileHandle), mFileMapping(other.mFileMapping)
+#endif
+{
+ other.mFileName = NULL;
+ other.mBasePtr = NULL;
+ other.mDataPtr = NULL;
+#if defined(__MINGW32__)
+ other.mFileHandle = 0;
+ other.mFileMapping = 0;
+#endif
+}
+
+// Move assign operator.
+FileMap& FileMap::operator=(FileMap&& other) {
+ mFileName = other.mFileName;
+ mBasePtr = other.mBasePtr;
+ mBaseLength = other.mBaseLength;
+ mDataOffset = other.mDataOffset;
+ mDataPtr = other.mDataPtr;
+ mDataLength = other.mDataLength;
+ other.mFileName = NULL;
+ other.mBasePtr = NULL;
+ other.mDataPtr = NULL;
+#if defined(__MINGW32__)
+ mFileHandle = other.mFileHandle;
+ mFileMapping = other.mFileMapping;
+ other.mFileHandle = 0;
+ other.mFileMapping = 0;
+#endif
+ return *this;
+}
+
// Destructor.
FileMap::~FileMap(void)
{