summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--thunk.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/thunk.h b/thunk.h
index d1f407e..4930f18 100644
--- a/thunk.h
+++ b/thunk.h
@@ -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
© All Rights Reserved