ooh!, comment should read + * if user fn returns 1, the enumeration can prematurely abort >
----- Original Message ----- From: "Guillaume Cottenceau" <[EMAIL PROTECTED]> To: "fred" <[EMAIL PROTECTED]> Cc: "devel" <[email protected]> Sent: Tuesday, February 22, 2005 10:11 PM Subject: Re: [PATCH] gwlib enumerate list function -#- MailID:MEAA > "fred" <fred 'at' 5thfinger.com> writes: > > > this is a new function, no code in the original kannel code uses it, but we are in various additions > > done here; its quite useful and neat and small..... > > cheers > > > > Index: list.c > > =================================================================== > > RCS file: /home/cvs/gateway/gwlib/list.c,v > > retrieving revision 1.42 > > diff -u -r1.42 list.c > > --- list.c 11 Feb 2005 15:35:48 -0000 1.42 > > +++ list.c 22 Feb 2005 02:41:10 -0000 > > @@ -649,3 +649,42 @@ > > list->len -= count; > > } > > } > > + > > +/** \brief enumerate items of a list > > + * > > + * enumerate thru the items of the list, calling the user supplied function > > + * with each item, plus optionally some environment structure. > > + * if user fn returns 0, the enumeration can prematurely abort > > non-zero ? > > [...] > > > + for (i = 0; i < list->len; ++i) > > + { > > + item = GET(list, i); > > + > > + if (fn(env,item)) > ^^^^^^^^^^^^^^^^^ > > > + break; > > + > > + } > > + if (i == list->len) > > + { > > + item = NULL; > > + } > > + unlock(list); > > + > > + return item; > > +} > > + > > > > -- > Guillaume Cottenceau
