-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit defines an iterator in the libctf _next style because it's *so much* nicer to use than the function-calling _iter form: extern void *dt_htab_next(const dt_htab_t *htab, dt_htab_next_t **it); extern void dt_htab_next_destroy(dt_htab_next_t *i); Call dt_htab_next with the htab to iterate over and a dt_htab_next_t initialized to NULL to allocate an iterator and return the first element. Subsequent calls with the allocated iterator will return further elements from the hash until iteration is complete, at which time the iterator is freed and reset to NULL, ready for another iteration cycle. There are no restrictions whatsoever on what you can do inside iteration (iterate over other things, iterate over the same thing, fork, longjmp out of it, etc) except that you should not delete hash entries that the iterator has not yet returned: if you insert new ones, they may or may not be returned by this iteration cycle. If you need to exit early or longjmp out, dt_htab_next_destroy frees the iterator for you. Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Reviewed-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
1 parent
1b022e4
commit 06ee554
Showing
4 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters