diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-10-02 01:31:53 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-02 01:31:53 +0000 |
commit | 7e59e17474e3be00104da417dc04a9824ab6404e (patch) | |
tree | 6dc501f2e7681de1620d9eafe6133c3609ed4030 | |
parent | dc53918efb984728bf27c34569e0326dce5b184e (diff) | |
parent | 0b2bce06382b5517a4dba33da5328c751f2c7a3e (diff) |
am 0b2bce06: am bda375fa: am c6c6ab50: Merge "Implement C++11 move semantics for android::FileMap"
* commit '0b2bce06382b5517a4dba33da5328c751f2c7a3e':
Implement C++11 move semantics for android::FileMap
-rw-r--r-- | include/utils/FileMap.h | 3 | ||||
-rw-r--r-- | libutils/FileMap.cpp | 37 |
2 files changed, 40 insertions, 0 deletions
diff --git a/include/utils/FileMap.h b/include/utils/FileMap.h index afd7bfd7b..7d372e1dc 100644 --- a/include/utils/FileMap.h +++ b/include/utils/FileMap.h @@ -52,6 +52,9 @@ class FileMap { public: FileMap(void); + FileMap(FileMap&& f); + FileMap& operator=(FileMap&& f); + /* * Create a new mapping on an open file. * 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) { |