mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -10,11 +10,11 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
size_t length = sizeof(ram->bytesTotal);
|
||||
|
||||
#if FF_APPLE_MEMSIZE_USABLE
|
||||
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, NULL, 0) != 0) {
|
||||
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, nullptr, 0) != 0) {
|
||||
return "Failed to read hw.memsize_usable";
|
||||
}
|
||||
#else
|
||||
if (sysctl((int[]) { CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0) {
|
||||
if (sysctl((int[]) { CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, nullptr, 0) != 0) {
|
||||
return "Failed to read hw.memsize";
|
||||
}
|
||||
#endif
|
||||
@@ -31,5 +31,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
uint64_t pagesFileBacked = vmstat.external_page_count; // Cached files
|
||||
ram->bytesUsed = ram->bytesTotal - (pagesFree + pagesFileBacked) * instance.state.platform.sysinfo.pageSize;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
size_t length = sizeof(ram->bytesTotal);
|
||||
if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0)) {
|
||||
if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, nullptr, 0)) {
|
||||
return "Failed to read hw.physmem";
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
ram->bytesUsed -= (uint64_t) bytesArc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
ram->bytesTotal = pageSize * info.max_pages;
|
||||
ram->bytesUsed = pageSize * info.used_pages;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -17,36 +17,36 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
cached = 0,
|
||||
sReclaimable = 0;
|
||||
|
||||
char* token = NULL;
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemTotal:", strlen("MemTotal:"))) != NULL) {
|
||||
memTotal = (uint64_t) strtoull(token + strlen("MemTotal:"), NULL, 10);
|
||||
char* token = nullptr;
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemTotal:", strlen("MemTotal:"))) != nullptr) {
|
||||
memTotal = (uint64_t) strtoull(token + strlen("MemTotal:"), nullptr, 10);
|
||||
} else {
|
||||
return "MemTotal not found in /proc/meminfo";
|
||||
}
|
||||
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemAvailable:", strlen("MemAvailable:"))) != NULL) {
|
||||
memAvailable = (uint64_t) strtoull(token + strlen("MemAvailable:"), NULL, 10);
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemAvailable:", strlen("MemAvailable:"))) != nullptr) {
|
||||
memAvailable = (uint64_t) strtoull(token + strlen("MemAvailable:"), nullptr, 10);
|
||||
}
|
||||
|
||||
if (memAvailable == 0 || memAvailable >= memTotal) { // MemAvailable can be unreasonable. #1988
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemFree:", strlen("MemFree:"))) != NULL) {
|
||||
memFree = (uint64_t) strtoull(token + strlen("MemFree:"), NULL, 10);
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemFree:", strlen("MemFree:"))) != nullptr) {
|
||||
memFree = (uint64_t) strtoull(token + strlen("MemFree:"), nullptr, 10);
|
||||
}
|
||||
|
||||
if ((token = memmem(buf, (size_t) nRead, "Buffers:", strlen("Buffers:"))) != NULL) {
|
||||
buffers = (uint64_t) strtoull(token + strlen("Buffers:"), NULL, 10);
|
||||
if ((token = memmem(buf, (size_t) nRead, "Buffers:", strlen("Buffers:"))) != nullptr) {
|
||||
buffers = (uint64_t) strtoull(token + strlen("Buffers:"), nullptr, 10);
|
||||
}
|
||||
|
||||
if ((token = memmem(buf, (size_t) nRead, "Cached:", strlen("Cached:"))) != NULL) {
|
||||
cached = (uint64_t) strtoull(token + strlen("Cached:"), NULL, 10);
|
||||
if ((token = memmem(buf, (size_t) nRead, "Cached:", strlen("Cached:"))) != nullptr) {
|
||||
cached = (uint64_t) strtoull(token + strlen("Cached:"), nullptr, 10);
|
||||
}
|
||||
|
||||
if ((token = memmem(buf, (size_t) nRead, "Shmem:", strlen("Shmem:"))) != NULL) {
|
||||
shmem = (uint64_t) strtoull(token + strlen("Shmem:"), NULL, 10);
|
||||
if ((token = memmem(buf, (size_t) nRead, "Shmem:", strlen("Shmem:"))) != nullptr) {
|
||||
shmem = (uint64_t) strtoull(token + strlen("Shmem:"), nullptr, 10);
|
||||
}
|
||||
|
||||
if ((token = memmem(buf, (size_t) nRead, "SReclaimable:", strlen("SReclaimable:"))) != NULL) {
|
||||
sReclaimable = (uint64_t) strtoull(token + strlen("SReclaimable:"), NULL, 10);
|
||||
if ((token = memmem(buf, (size_t) nRead, "SReclaimable:", strlen("SReclaimable:"))) != nullptr) {
|
||||
sReclaimable = (uint64_t) strtoull(token + strlen("SReclaimable:"), nullptr, 10);
|
||||
}
|
||||
|
||||
memAvailable = memFree + buffers + cached + sReclaimable - shmem;
|
||||
@@ -65,25 +65,25 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
|
||||
// Skip first line
|
||||
const char* p = memchr(buf, '\n', (size_t) nRead);
|
||||
if (__builtin_expect(p != NULL, true)) {
|
||||
if (__builtin_expect(p != nullptr, true)) {
|
||||
++p;
|
||||
nRead -= (p - buf);
|
||||
assert(nRead > 0);
|
||||
|
||||
// Find line offset of data
|
||||
const char* pData = memmem(p, (size_t) nRead, "data\n", strlen("data\n"));
|
||||
if (__builtin_expect(pData != NULL, true)) {
|
||||
if (__builtin_expect(pData != nullptr, true)) {
|
||||
uint32_t dataOffset = (uint32_t) (pData - p);
|
||||
p += dataOffset + strlen("data\n");
|
||||
nRead -= (ssize_t) (dataOffset + strlen("data\n"));
|
||||
assert(nRead > 0);
|
||||
|
||||
if ((token = memmem(p, (size_t) nRead, "\nsize ", strlen("\nsize "))) != NULL) {
|
||||
arcSize = (uint64_t) strtoull(token + 1 + dataOffset, NULL, 10);
|
||||
if ((token = memmem(p, (size_t) nRead, "\nsize ", strlen("\nsize "))) != nullptr) {
|
||||
arcSize = (uint64_t) strtoull(token + 1 + dataOffset, nullptr, 10);
|
||||
if (arcSize > 0) {
|
||||
uint64_t arcMin = 0;
|
||||
if ((token = memmem(p, (size_t) nRead, "\nc_min ", strlen("\nc_min "))) != NULL) {
|
||||
arcMin = (uint64_t) strtoull(token + 1 + dataOffset, NULL, 10);
|
||||
if ((token = memmem(p, (size_t) nRead, "\nc_min ", strlen("\nc_min "))) != nullptr) {
|
||||
arcMin = (uint64_t) strtoull(token + 1 + dataOffset, nullptr, 10);
|
||||
if (arcSize > arcMin) {
|
||||
arcSize -= arcMin;
|
||||
if (ram->bytesUsed > arcSize) {
|
||||
@@ -97,5 +97,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
struct uvmexp_sysctl buf;
|
||||
size_t length = sizeof(buf);
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, NULL, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, nullptr, 0) < 0) {
|
||||
return "sysctl(CTL_VM, VM_UVMEXP2) failed";
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
ram->bytesUsed -= (uint64_t) bytesArc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
struct uvmexp buf;
|
||||
size_t length = sizeof(buf);
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, NULL, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, nullptr, 0) < 0) {
|
||||
return "sysctl(CTL_VM, VM_UVMEXP) failed";
|
||||
}
|
||||
|
||||
ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize;
|
||||
ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
ram->bytesUsed = ram->bytesTotal - (uint64_t) sysconf(_SC_AVPHYS_PAGES) * pageSize;
|
||||
|
||||
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
|
||||
if (kc != NULL) {
|
||||
if (kc != nullptr) {
|
||||
kstat_t* ksp = kstat_lookup(kc, "zfs", -1, "arcstats");
|
||||
if (ksp != NULL && kstat_read(kc, ksp, NULL) != -1) {
|
||||
if (ksp != nullptr && kstat_read(kc, ksp, nullptr) != -1) {
|
||||
kstat_named_t* kn_size = (kstat_named_t*) kstat_data_lookup(ksp, "size");
|
||||
kstat_named_t* kn_cmin = (kstat_named_t*) kstat_data_lookup(ksp, "c_min");
|
||||
|
||||
if (kn_size != NULL && kn_cmin != NULL &&
|
||||
if (kn_size != nullptr && kn_cmin != nullptr &&
|
||||
kn_size->data_type == KSTAT_DATA_UINT64 &&
|
||||
kn_cmin->data_type == KSTAT_DATA_UINT64) {
|
||||
uint64_t arcSize = kn_size->value.ui64;
|
||||
@@ -39,5 +39,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
|
||||
ram->bytesTotal = statex.ullTotalPhys;
|
||||
ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user