summaryrefslogtreecommitdiffstats
path: root/libutils
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-10-02 01:25:31 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-10-02 01:25:31 +0000
commit0b2bce06382b5517a4dba33da5328c751f2c7a3e (patch)
treeab384974f961fe0872ff1ecdd39f0df41c4d8dde /libutils
parent09b7c05affce37efd5a5236a0b55e46cc88ae3f8 (diff)
parentbda375fa41c88e6b2f81a8cd88fc5fdda62bc723 (diff)
downloadcore-0b2bce06382b5517a4dba33da5328c751f2c7a3e.tar.gz
core-0b2bce06382b5517a4dba33da5328c751f2c7a3e.tar.bz2
core-0b2bce06382b5517a4dba33da5328c751f2c7a3e.zip
am bda375fa: am c6c6ab50: Merge "Implement C++11 move semantics for android::FileMap"
* commit 'bda375fa41c88e6b2f81a8cd88fc5fdda62bc723': Implement C++11 move semantics for android::FileMap
Diffstat (limited to 'libutils')
-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)
{