more flexible parsing for /proc/meminfo to take shared and reclaimable
memory into account. this matches the output with free(1).
additionally this could fix some corner cases, as the order of fields in
/proc/meminfo is not strictly defined.
slstatus:
percent 81% free 2.5 Gi total 23.4 Gi used 19.0 Gi
free(1):
total used free shared buff/cache available
Mem: 23Gi 19Gi 2.5Gi 1.3Gi 3.2Gi 3.6Gi
19 lines
519 B
C
19 lines
519 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
extern char buf[1024];
|
|
|
|
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
extern char *argv0;
|
|
|
|
void warn(const char *, ...);
|
|
void die(const char *, ...);
|
|
|
|
int esnprintf(char *str, size_t size, const char *fmt, ...);
|
|
const char *bprintf(const char *fmt, ...);
|
|
const char *fmt_human(uintmax_t num, int base);
|
|
int pscanf(const char *path, const char *fmt, ...);
|
|
int lscanf(FILE *fp, const char *key, const char *fmt, void *res);
|