summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-06-25 16:54:36 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-06-25 16:54:36 +0000
commit55fe185ec48e6997502b09d21702230957147d38 (patch)
treee6d64ae5f771a7015178b135dbf5813e75fb46ef
parentfb3227b6f6e2a924a85917b41f5ea40c6bd90521 (diff)
handle missing swap
-rw-r--r--usr.bin/top/machine.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 198588914a7..52eb7112bcf 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machine.c,v 1.8 1997/11/08 23:36:44 millert Exp $ */
+/* $OpenBSD: machine.c,v 1.9 1998/06/25 16:54:35 deraadt Exp $ */
/*
* top - a top users display for Unix
@@ -693,6 +693,11 @@ int *total;
KGET(VM_DMMAX, dmmax);
KGET(VM_NSWAPMAP, nswapmap);
KGET(VM_SWAPMAP, kswapmap); /* kernel `swapmap' is a pointer */
+ if (nswap == 0) {
+ *used = 0;
+ *total = 0;
+ return (1);
+ }
if ((sw = malloc(nswdev * sizeof(*sw))) == NULL ||
(perdev = malloc(nswdev * sizeof(*perdev))) == NULL ||
(freemp = mp = malloc(nswapmap * sizeof(*mp))) == NULL)