summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-08-03 17:38:06 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-08-04 22:50:10 +0200
commit861feef2bfd879f4cb62ca67cff42314b355e03a (patch)
treee22f798ca5f6689141b5ce2f432b48db4baff7b4 /src
parentc99849d0bc72df31ffde26c9ebffbf152cfcaeae (diff)
QFsFileEngine (Unix): replace a QPair with a proper struct
The comments in the declaration of the pair screamed "I want to be a struct with properly-named member variables", and the code that read it->first and it->second was really misleading to STL-aware readers. Fix by defining a small struct with member names taken from unmap()'s use of the pair's fields. Change-Id: Ie18852a3147f65cf14cfc5a3bb633f7b3e78f5a2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfsfileengine_p.h6
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index d6e7ecb592..f5236a0156 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -197,7 +197,11 @@ public:
mutable int cachedFd;
mutable DWORD fileAttrib;
#else
- QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
+ struct StartAndLength {
+ int start; // offset % PageSize
+ size_t length; // length + offset % PageSize
+ };
+ QHash<uchar *, StartAndLength> maps;
#endif
int fd;
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 0b3e401be8..484a60fb74 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -621,7 +621,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
access, sharemode, nativeHandle(), realOffset);
if (MAP_FAILED != mapAddress) {
uchar *address = extra + static_cast<uchar*>(mapAddress);
- maps[address] = QPair<int,size_t>(extra, realSize);
+ maps[address] = {extra, realSize};
return address;
}
@@ -652,8 +652,8 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr)
return false;
}
- uchar *start = ptr - it->first;
- size_t len = it->second;
+ uchar *start = ptr - it->start;
+ size_t len = it->length;
if (-1 == munmap(start, len)) {
q->setError(QFile::UnspecifiedError, qt_error_string(errno));
return false;