[DTrace-devel] [PATCH v2 08/11] htab: add a _next-style iterator

Eugene Loh eugene.loh at oracle.com
Fri Oct 22 13:43:31 PDT 2021


On 10/22/21 3:03 PM, Eugene Loh wrote:

> On 10/20/21 2:54 PM, Nick Alcock wrote:
>> There are no restrictions whatsoever on what you can do inside iteration
>> (iterate over other things, fork, longjmp out of it, you name it) except
>> for deleting the hash entry you're iterating over: for that, we have
>> dt_htab_next_delete.
>
> I'm unsure why there is a next_delete function in the first place....
> I'm just thinking here.  Again, no need for anyone here to be making a 
> career out of these functions.
Another option is to have the iterator do something like:
     while (entry == NULL) advance one entry;
     retval = entry;
     advance one entry;
     return retval;
That way, the caller can delete the current item.  No need for 
next_delete() or .prev or messy commit-message explanations or repeating 
elements.



More information about the DTrace-devel mailing list