get rid of read to str

This commit is contained in:
2025-12-14 15:02:23 +01:00
parent a271711441
commit bc3f911f60
4 changed files with 9 additions and 16 deletions

View File

@@ -28,9 +28,10 @@ void sys::getTimeDate(TimeDate* td) {
}
void sys::getRam(Memory* mem) {
auto content = readFileToStr("/proc/meminfo", 128); // file is longer than that but its all we need
mem->free = getVal("MemAvailable:", content);
mem->total = getVal("MemTotal:", content);
static char buf[128]; // file is longer but we only need first 128 chars
readFile("/proc/meminfo", buf, sizeof(buf));
mem->free = getVal("MemAvailable:", std::string_view(buf));
mem->total = getVal("MemTotal:", std::string_view(buf));
mem->used = mem->total - mem->free;
}