-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abd: abd_for_each_chunk with automatic setup & cleanup
By making the loop block an arg to the macro, we can wrap it, and solve both the problems in the previous version. We can declare the data & size vars ourselves, so the caller doesn't have to, and we can run at loop exit, so can unmap the chunk properly (alas, we can't do it for an early return, but that's a much rarer thing to want than an early break). The cost is a tiny bit of readbility, as a code block as a macro arg is a little less familiar than one following a loop operator. The extra safety seems worth it to me.
- Loading branch information
Showing
2 changed files
with
50 additions
and
66 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