Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6c6ab50 authored by Adam Lesinski's avatar Adam Lesinski Committed by Gerrit Code Review
Browse files

Merge "Implement C++11 move semantics for android::FileMap"

parents 17cd2c49 6f8885bc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ class FileMap {
public:
    FileMap(void);

    FileMap(FileMap&& f);
    FileMap& operator=(FileMap&& f);

    /*
     * Create a new mapping on an open file.
     *
+37 −0
Original line number Diff line number Diff line
@@ -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)
{