} else if (startswith(line, "MemAvailable:")) {
snprintf(lbuf, 100, "MemAvailable: %8lu kB\n", memlimit - memusage + cached);
printme = lbuf;
- } else if (startswith(line, "SwapTotal:") && memswlimit > 0 && opts->swap_off == false) {
+ } else if (startswith(line, "SwapTotal:") && memswlimit > 0 && opts && opts->swap_off == false) {
sscanf(line+sizeof("SwapTotal:")-1, "%lu", &hostswtotal);
if (hostswtotal < memswlimit)
memswlimit = hostswtotal;
snprintf(lbuf, 100, "SwapTotal: %8lu kB\n", memswlimit);
printme = lbuf;
- } else if (startswith(line, "SwapTotal:") && opts->swap_off == true) {
+ } else if (startswith(line, "SwapTotal:") && opts && opts->swap_off == true) {
snprintf(lbuf, 100, "SwapTotal: %8lu kB\n", 0UL);
printme = lbuf;
- } else if (startswith(line, "SwapFree:") && memswlimit > 0 && memswusage > 0 && opts->swap_off == false) {
+ } else if (startswith(line, "SwapFree:") && memswlimit > 0 && memswusage > 0 && opts && opts->swap_off == false) {
unsigned long swaptotal = memswlimit,
swapusage = memswusage - memusage,
swapfree = swapusage < swaptotal ? swaptotal - swapusage : 0;
snprintf(lbuf, 100, "SwapFree: %8lu kB\n", swapfree);
printme = lbuf;
- } else if (startswith(line, "SwapFree:") && opts->swap_off == true) {
+ } else if (startswith(line, "SwapFree:") && opts && opts->swap_off == true) {
snprintf(lbuf, 100, "SwapFree: %8lu kB\n", 0UL);
printme = lbuf;
} else if (startswith(line, "Slab:")) {