[Oracle] Apply clang-format to the memory querier

This commit is contained in:
Lukas Brübach 2026-11-01 21:39:27 +01:00
parent 88ee27b7f0
commit 2e77270cb8

View file

@ -23,15 +23,17 @@ qulonglong SystemMemoryQuerier::totalMemoryBytes()
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
if (GlobalMemoryStatusEx(&statex))
if (GlobalMemoryStatusEx(&statex)) {
return statex.ullTotalPhys;
}
return 0;
#elif defined(Q_OS_LINUX)
QFile file("/proc/meminfo");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return 0;
}
QTextStream in(&file);
while (!in.atEnd()) {
@ -42,8 +44,9 @@ qulonglong SystemMemoryQuerier::totalMemoryBytes()
#else
QStringList parts = line.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
#endif
if (parts.size() >= 2)
if (parts.size() >= 2) {
return parts[1].toULongLong() * 1024; // kB → bytes
}
}
}
return 0;
@ -54,8 +57,9 @@ qulonglong SystemMemoryQuerier::totalMemoryBytes()
qulonglong memsize = 0;
size_t len = sizeof(memsize);
if (sysctl(mib, 2, &memsize, &len, nullptr, 0) == 0)
if (sysctl(mib, 2, &memsize, &len, nullptr, 0) == 0) {
return memsize;
}
return 0;
@ -70,15 +74,17 @@ qulonglong SystemMemoryQuerier::availableMemoryBytes()
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
if (GlobalMemoryStatusEx(&statex))
if (GlobalMemoryStatusEx(&statex)) {
return statex.ullAvailPhys;
}
return 0;
#elif defined(Q_OS_LINUX)
QFile file("/proc/meminfo");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return 0;
}
QTextStream in(&file);
while (!in.atEnd()) {
@ -89,8 +95,9 @@ qulonglong SystemMemoryQuerier::availableMemoryBytes()
#else
QStringList parts = line.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
#endif
if (parts.size() >= 2)
if (parts.size() >= 2) {
return parts[1].toULongLong() * 1024;
}
}
}
return 0;
@ -103,8 +110,9 @@ qulonglong SystemMemoryQuerier::availableMemoryBytes()
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
vm_statistics64_data_t vmstat;
if (host_statistics64(mach_host_self(), HOST_VM_INFO, (host_info64_t)&vmstat, &count) != KERN_SUCCESS)
if (host_statistics64(mach_host_self(), HOST_VM_INFO, (host_info64_t)&vmstat, &count) != KERN_SUCCESS) {
return 0;
}
qulonglong freeBytes = (qulonglong)vmstat.free_count * (qulonglong)pageSize;