Subject: Re: calendar vs. NIS
To: tech-userlevel <>
From: Joerg Klemenz <>
List: tech-userlevel
Date: 11/07/2002 13:59:24
David Laight wrote:
> I guess if there are enough users to make a linear scan impratical
> then the program won't finishe overnight anyway!

If your computer has UID_MAX users and < 1 MHz

This version uses a semi-efficient reverse-sorted list. It also has
the compact code and indescriptive variable names that professionals
seem to value.

The performance penalty for regular use is near zero with the reverse
sorting and swapping algorithm. NIS users still get an OK performance.
Also note that it needs several thousand times more cycles to look up
something in NIS than to walk the list.

static int                           
inuidlist(uidlist_ptr, uid)                           
    struct uidlist_s *uidlist_ptr;                           
    uid_t uid;                           
   struct uidlist_s *p,*tmp;                           
   for (p=uidlist_ptr; p->next && (p->uid > uid); p=p->next);   
   if ((p->uid==uid) && p->next) return (1);                           
   if (tmp=malloc(sizeof *tmp)) {                           
   return (0);                           

	joerg  <>