diff options
| author | Anser <rostgans@tutamail.com> | 2026-08-11 00:18:57 +0200 |
|---|---|---|
| committer | Anser <rostgans@tutamail.com> | 2026-08-11 00:18:57 +0200 |
| commit | eb6f986361713d6ce47c6d4572bb24d9f6207ddf (patch) | |
| tree | 3fca62d5cad785acce36a46a660219840c959932 /src/memory.c | |
| parent | 9ad584b5762433f7c99d7cc7b65ad21ebe4ff932 (diff) | |
TOBESQUISHED: safe in reconstruction of the codes layout and rework of information handeling also ascii art printing
Diffstat (limited to 'src/memory.c')
| -rw-r--r-- | src/memory.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/memory.c b/src/memory.c new file mode 100644 index 0000000..9e880d2 --- /dev/null +++ b/src/memory.c @@ -0,0 +1,26 @@ +#include "../include/cfetch.h" + +void get_memory(system_info_t *info) { + FILE *file = fopen("/proc/meminfo", "r"); + + if (!file) { + perror("Error fopen meminfo"); + return; + } + + char line[256]; + long total = 0; + long available = 0; + + // read per line + while (fgets(line, sizeof(line), file)) { + if (sscanf(line, "MemTotal: %ld kB", &total) == 1) continue; + if (sscanf(line, "MemAvailable: %ld kB", &available) == 1) continue; + } + + fclose(file); + + printf("Memory: %.2f GB / %.2f GB\n", (total - available) / (1024.0 * 1024.0), total / (1024.0 * 1024.0)); + + return; +} |
