[BACK]Return to machine.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / top

Diff for /src/usr.bin/top/machine.c between version 1.23 and 1.24

version 1.23, 2001/02/22 03:10:24 version 1.24, 2001/06/03 06:46:47
Line 274 
Line 274 
         int op, arg;          int op, arg;
         int *cnt;          int *cnt;
 {  {
         size_t size = 0;          size_t size = sizeof(int);
         int mib[4] = {CTL_KERN, KERN_PROC, op, arg};          int mib[4] = {CTL_KERN, KERN_PROC, op, arg};
         int st, nprocs;          int smib[2] = {CTL_KERN, KERN_NPROCS};
         static struct kinfo_proc *procbase;          static struct kinfo_proc *procbase;
           int st;
   
         st = sysctl(mib, 4, NULL, &size, NULL, 0);          st = sysctl(smib, 2, cnt, &size, NULL, 0);
         if (st == -1) {          if (st == -1) {
                 /* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */                  /* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */
                 return (0);                  return (0);
         }          }
         if (procbase)          if (procbase)
                 free(procbase);                  free(procbase);
           size = (6 * (*cnt) * sizeof(struct kinfo_proc)) / 5;
         procbase = (struct kinfo_proc *)malloc(size);          procbase = (struct kinfo_proc *)malloc(size);
         if (procbase == NULL)          if (procbase == NULL)
                 return (0);                  return (0);
Line 300 
Line 302 
                     size, sizeof(struct kinfo_proc)); */                      size, sizeof(struct kinfo_proc)); */
                 return (0);                  return (0);
         }          }
         *cnt = size / sizeof(struct kinfo_proc);  
         return (procbase);          return (procbase);
 }  }
   

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24