This change introduces the glob_b function which takes a block instead
of a function pointer.
Relnotes: yes
Sponsored by: Klara, Inc.
Obtained from: https://github.com/apple-oss-distributions/Libc
Differential D50485
glob: Add blocks support bnovkov on Fri, May 23, 2:39 PM. Authored by Tags None Referenced Files
Details This change introduces the glob_b function which takes a block instead Relnotes: yes
Diff Detail
Event TimelineComment Actions David historically has views on blocks, lets solicit his opinion as well.
Comment Actions I'm not quite sure what this is doing, but it isn't following the pattern that the rest of libc uses. We have DECLARE_BLOCK to declare a block type in a compiler-agnostic way and then CALL_BLOCK to call it. You don't need most of the #ifdef __BLOCKS__ bits at all, they're all handled by the abstraction layer. See block_abi.h. If I understand the API of glob[_b] correctly, the block is not captured after the call, it is simply passed down and invoked. If so, this is *all* that is needed, since you don't need any of the memory-management bits that complicated fts_b.
Comment Actions This is also missing an update to the man page. The HISTORY bit should mention that glob_b first appeared in OS X 10.6. Comment Actions Address @theraven 's comments:
Comment Actions Thank you for the feedback, I managed to miss the block_abi.h header. I've updated the diff to use the block_abi.h macros and removed the unnecessary ifdef blocks.
Comment Actions LGTM, assuming I understand the memory management correctly. I would be happier if something zeroed the gl_errblk field at the end of the call, because otherwise it is a dangling pointer. I don't *think* there's any code path that can reach it, but it's good practice to ensure that any pointer is either to a valid object or null.
|