Subject: Re: calendar vs. NIS
To: Joerg Klemenz <joerg@gmx.net>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 11/06/2002 20:48:49
> 
> Uhh... that sounds complicated. How about that (it's kinda lame, but
> should work for all cases)

I guess if there are enough users to make a linear scan impratical
then the program won't finishe overnight anyway!

This shouldn't be needed...
> +        /* create the tail of the linked list */
> +        uidlist_ptr=(struct uidlist_s*)malloc(sizeof(struct uidlist_s));
> +        if (uidlist_ptr==NULL) malloc_panic;
> +        uidlist_ptr->next=NULL;

Spot the windows programmer (no unix person uses mixed case names).
> +static int 
> +checkForDoubleUID(uidlist_ptr,uid)

Nor 22 character names when 1 will suffice...
> +   struct uidlist_s *working_uidlist_ptr;

This looks awry...
just do:
	struct uidlist_s *p;

	for (p = uidlist_ptr; p; p = p->next)
		if (p->uid == uid)
			return 1;
	p = malloc(sizeof *p);
	if (p) {
		p->uid = uid;
		p->next = uidlist_ptr;
		uidlist_ptr = p;
	}
	return 0;

Although it would be faster to block up lots of uids in each item.
Or even just have a single data item that you realloc when there
isn't enough space.

	David

-- 
David Laight: david@l8s.co.uk