=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/top/machine.c,v retrieving revision 1.23 retrieving revision 1.24 diff -c -r1.23 -r1.24 *** src/usr.bin/top/machine.c 2001/02/22 03:10:24 1.23 --- src/usr.bin/top/machine.c 2001/06/03 06:46:47 1.24 *************** *** 1,4 **** ! /* $OpenBSD: machine.c,v 1.23 2001/02/22 03:10:24 deraadt Exp $ */ /* * top - a top users display for Unix --- 1,4 ---- ! /* $OpenBSD: machine.c,v 1.24 2001/06/03 06:46:47 angelos Exp $ */ /* * top - a top users display for Unix *************** *** 274,291 **** int op, arg; int *cnt; { ! size_t size = 0; int mib[4] = {CTL_KERN, KERN_PROC, op, arg}; ! int st, nprocs; static struct kinfo_proc *procbase; ! st = sysctl(mib, 4, NULL, &size, NULL, 0); if (st == -1) { /* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */ return (0); } if (procbase) free(procbase); procbase = (struct kinfo_proc *)malloc(size); if (procbase == NULL) return (0); --- 274,293 ---- int op, arg; int *cnt; { ! size_t size = sizeof(int); int mib[4] = {CTL_KERN, KERN_PROC, op, arg}; ! int smib[2] = {CTL_KERN, KERN_NPROCS}; static struct kinfo_proc *procbase; + int st; ! st = sysctl(smib, 2, cnt, &size, NULL, 0); if (st == -1) { /* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */ return (0); } if (procbase) free(procbase); + size = (6 * (*cnt) * sizeof(struct kinfo_proc)) / 5; procbase = (struct kinfo_proc *)malloc(size); if (procbase == NULL) return (0); *************** *** 300,306 **** size, sizeof(struct kinfo_proc)); */ return (0); } - *cnt = size / sizeof(struct kinfo_proc); return (procbase); } --- 302,307 ----