getmem some fixes

This commit is contained in:
Your Name 2023-12-16 19:04:59 +03:00
parent d4571a3f14
commit eabba8f4ea

View File

@ -2,6 +2,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/utsname.h>
@ -191,12 +192,12 @@ int GetMem(const char *title, const FETCH fetch) {
if (fp == NULL)
return 1;
unsigned int unused = 0, total = 0, available = 0, buffer = 0, cached = 0;
if (fscanf(fp, "MemTotal: %u kB\nMemFree: %u kB\nMemAvailable: %u kB\nBuffers: %u kB\nCached: %u kB", &total, &unused, &available, &buffer, &cached) < 0)
off_t unused = 0, total = 0, available = 0;
if (fscanf(fp, "MemTotal: %ju kB\nMemFree: %ju kB\nMemAvailable: %ju kB", &total, &unused, &available) < 0)
return 1;
UNUSED(unused);
printf("%s%s%s%umb / %umb", fetch.color, title, fetch.font_color, (total - available - buffer - cached) / 1024, total / 1024);
printf("%s%s%s%jumb / %jumb", fetch.color, title, fetch.font_color, (uintmax_t)(total - available) / 1024, (uintmax_t)total / 1024);
fclose(fp);
return 0;