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

Diff for /src/usr.bin/top/utils.c between version 1.15 and 1.16

version 1.15, 2004/11/22 15:26:53 version 1.16, 2005/06/08 22:36:43
Line 34 
Line 34 
   
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/sysctl.h>  #include <sys/sysctl.h>
   #include <err.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 162 
Line 163 
         cnt += 3;          cnt += 3;
   
         /* allocate a char * array to hold the pointers */          /* allocate a char * array to hold the pointers */
         argarray = (char **) malloc(cnt * sizeof(char *));          if ((argarray = malloc(cnt * sizeof(char *))) == NULL)
                   err(1, NULL);
   
         /* allocate another array to hold the strings themselves */          /* allocate another array to hold the strings themselves */
         args = (char *) malloc(length + 2);          if ((args = malloc(length + 2)) == NULL)
                   err(1, NULL);
   
         /* initialization for main loop */          /* initialization for main loop */
         from = line;          from = line;
Line 207 
Line 210 
  * useful on BSD mchines for calculating cpu state percentages.   * useful on BSD mchines for calculating cpu state percentages.
  */   */
 int  int
 percentages(int cnt, int *out, long *new, long *old, long *diffs)  percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
 {  {
         long change, total_change, *dp, half_total;          int64_t change, total_change, *dp, half_total;
         int i;          int i;
   
         /* initialization */          /* initialization */
Line 220 
Line 223 
         for (i = 0; i < cnt; i++) {          for (i = 0; i < cnt; i++) {
                 if ((change = *new - *old) < 0) {                  if ((change = *new - *old) < 0) {
                         /* this only happens when the counter wraps */                          /* this only happens when the counter wraps */
                         change = ((unsigned int)*new - (unsigned int)*old);                          change = (*new - *old);
                 }                  }
                 total_change += (*dp++ = change);                  total_change += (*dp++ = change);
                 *old++ = *new++;                  *old++ = *new++;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16