>> Attached is a patch (not even compile tested yet) to add the _FOREACH_SAFE >> macros and also _NEXT and _PREV as well. >> Does this look good or have I made a schoolboy error somewhere? > > This one might even compile!
Do your _SAFE variants work for rbtrees with just one element?