[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Handlers
From: |
Neal H. Walfield |
Subject: |
Re: Handlers |
Date: |
Fri, 29 Aug 2008 15:27:21 +0200 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/21.4 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI) |
I know know why you call this a handler; it seems to me that it is
just a semi-generic list package. Am I missing something?
You can find a slighly more flexible and generic implementation here:
http://cvs.savannah.gnu.org/viewvc/hurd-l4/viengoos/list.h?root=hurd&view=markup
I've been using that for a while and am quite satisfied with it.
Perhaps you'll find it useful.
Neal
Two comments:
At Fri, 29 Aug 2008 14:36:56 +0200,
Marco Gerards wrote:
> +void
> +grub_handler_unregister (grub_handler_t *head, grub_handler_t handler)
> +{
> + grub_handler_t *p, q;
> +
> + for (p = head, q = *p; q; p = &(q->next), q = q->next)
^^^^^^ ^^^^^^^^^^^
This is a bit inconsistent.
for (p = head, q = *head; q; p = &(q->next), q = q->next)
or
for (p = head, q = *p; q; p = &(q->next), q = *p)
Or, more succinctly:
for (p = head; (q = *p); p = &(q->next))
> +int
> +grub_handler_iterate (grub_handler_t head,
> + int (*hook) (const grub_handler_t handler))
> +{
> + grub_handler_t p;
> +
> + for (p = head; p; p = p->next)
> + if (hook (p))
> + break;
> +
> + return 0;
> +}
A suggestion: when HOOK returns a non-zero value, return that from the
function:
for (p = head; p; p = p->next)
{
int ret = hook (p);
if (ret)
return ret;
}
return 0;
- Handlers, Marco Gerards, 2008/08/29
- Re: Handlers,
Neal H. Walfield <=
- Re: Handlers, Vesa Jääskeläinen, 2008/08/29
Re: Handlers, Robert Millan, 2008/08/30