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>
This commit is contained in:
parent
c99849d0bc
commit
861feef2bf
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user