log mmap() result address

This commit is contained in:
guoling
2024-01-09 17:40:05 +08:00
parent a6f16b5c5e
commit 80a27ff49e
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -192,13 +192,14 @@ bool MemoryFile::msync(SyncFlag syncFlag) {
}
bool MemoryFile::mmap() {
auto oldPtr = m_ptr;
m_ptr = (char *) ::mmap(m_ptr, m_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_diskFile.m_fd, 0);
if (m_ptr == MAP_FAILED) {
MMKVError("fail to mmap [%s], %s", m_diskFile.m_path.c_str(), strerror(errno));
m_ptr = nullptr;
return false;
}
MMKVInfo("mmap to address [%p], oldPtr [%p], [%s]", m_ptr, oldPtr, m_diskFile.m_path.c_str());
return true;
}