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; _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel