[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: interface groups
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Re: interface groups
- From: David Gwynne <loki_(_at_)_animata_(_dot_)_net>
- Date: Wed, 23 Jun 2004 13:52:52 +1000
- Delivery-date: Wed, 23 Jun 2004 03:52:56 +0000
- Envelope-to: tech@openbsd.org
On Wed, 2004-06-23 at 13:32, Artur Grabowski wrote:
> Henning Brauer <lists-openbsdtech_(_at_)_bsws_(_dot_)_de> writes:
>
> > * Philipp Buehler <pb_(_at_)_openbsd_(_dot_)_org> [2004-06-22 10:06]:
> > > + TAILQ_FOREACH(ifgp, &ifp->if_groups, group_list) {
> > > + TAILQ_REMOVE(&ifp->if_groups, ifgp, group_list);
> >
> > no... see manpage
> >
> > NOTES
> > Trying to free a list in the following way is a common error:
> >
> > LIST_FOREACH(var, head, entry)
> > free(var);
> > free(head);
> >
> > Since var is free'd, the FOREACH() macro refers to a pointer that may
> > have been reallocated already. Proper code needs a second variable.
> >
> > for (var = LIST_FIRST(head); var != LIST_END(head); var = nxt) {
> > nxt = LIST_NEXT(var, entry);
> > free(var);
> > }
> > LIST_INIT(head); /* to put the list back in order */
>
> Stop giving bad advice. :)
>
> while ((foo = TAILQ_FIRST(..)) != NULL) {
> TAILQ_REMOVE(foo ...);
> free(foo);
> }
Hennings advice is good if you're not removing every entry in the list
as you loop through it.
>
> //art
>
--
Scanned and found clear by entirescan http://www.entirescan.com/
Visit your host, monkey.org