diff options
Diffstat (limited to 'thunk.h')
-rw-r--r-- | thunk.h | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -726,4 +726,21 @@ static inline void thunk_free(thunk_t *thunk) { return thunk->free(thunk); } + +/* Convenience helper for turning all successful thunk returns into + * don't-free/reuse successful returns, while still propagating errors. + */ +static inline int thunk_mid(int r) +{ + return (r < 0) ? r : 1; +} + +/* Convenience helper for turning all successful thunk returns into + * yes-free/discard successful returns, while still propagating errors. + */ +static inline int thunk_end(int r) +{ + return (r < 0) ? r : 0; +} + #endif |