[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interface groups

* 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

     Trying to free a list in the following way is a common error:

           LIST_FOREACH(var, head, entry)

     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);
           LIST_INIT(head);        /* to put the list back in order */

http://2suck.net/hhwl.html - http://www.bsws.de/
Unix is very simple, but it takes a genius to understand the simplicity.
(Dennis Ritchie)