Project

General

Profile

Bug #14591

Updated by Yuri Pankov 5 months ago

This puzzled me a bit, so I have taken the following logic from @STAILQ_FOREACH_SAFE@ to safely remove specific the entries while walking the list, which could be documented in the man page: 
 <pre> 
 list_t list; 
 foo_t foo, tfoo; 
 ... 
 for (foo = list_head(&list); foo != NULL && (tfoo = list_next(&list, foo), 1); foo = tfoo) { 
     ... 
     if (condition) 
         list_remove(&list, foo); 
 } 
 </pre> 

 It is not ideal, of course, so if there is any better solution, that could be added instead.

Back