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

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

version 1.15, 2008/04/02 16:41:24 version 1.16, 2009/07/22 15:27:52
Line 61 
Line 61 
         char    name[_PW_NAME_LEN + 1];          char    name[_PW_NAME_LEN + 1];
 };  };
   
 static int      enter_user(uid_t, char *, int);  static int      enter_user(uid_t, char *);
 static int      get_user(uid_t);  static int      get_user(uid_t);
   
 #define is_empty_hash(x)        (hash_table[x].name[0] == 0)  #define is_empty_hash(x)        (hash_table[x].name[0] == 0)
Line 99 
Line 99 
                 return ((uid_t)-1);                  return ((uid_t)-1);
   
         /* enter the result in the hash table */          /* enter the result in the hash table */
         enter_user(pwd->pw_uid, username, 1);          enter_user(pwd->pw_uid, username);
   
         /* return our result */          /* return our result */
         return (pwd->pw_uid);          return (pwd->pw_uid);
 }  }
   
 /*  
  * wecare: 1 = enter it always, 0 = nice to have  
  */  
 static int  static int
 enter_user(uid_t uid, char *name, int wecare)  enter_user(uid_t uid, char *name)
 {  {
         int hashindex;          int hashindex;
   
 #ifdef DEBUG  #ifdef DEBUG
         fprintf(stderr, "enter_hash(%u, %s, %d)\n", uid, name, wecare);          fprintf(stderr, "enter_hash(%u, %s)\n", uid, name);
 #endif  #endif
   
         hashindex = hashit(uid);          hashindex = hashit(uid);
   
         if (!is_empty_hash(hashindex)) {          if (!is_empty_hash(hashindex)) {
                 if (!wecare)  
                         return 0;       /* Don't clobber a slot for trash */  
                 if (hash_table[hashindex].uid == uid)                  if (hash_table[hashindex].uid == uid)
                         return (hashindex);     /* Fortuitous find */                          return (hashindex);     /* Fortuitous find */
         }          }
Line 142 
Line 137 
   
         /* no performance penalty for using getpwuid makes it easy */          /* no performance penalty for using getpwuid makes it easy */
         if ((pwd = getpwuid(uid)) != NULL)          if ((pwd = getpwuid(uid)) != NULL)
                 return (enter_user(pwd->pw_uid, pwd->pw_name, 1));                  return (enter_user(pwd->pw_uid, pwd->pw_name));
   
         /* if we can't find the name at all, then use the uid as the name */          /* if we can't find the name at all, then use the uid as the name */
         return (enter_user(uid, format_uid(uid), 1));          return (enter_user(uid, format_uid(uid)));
 }  }

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