diff options
Diffstat (limited to 'thunk.h')
-rw-r--r-- | thunk.h | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -459,7 +459,6 @@ struct thunk_t { assert(env); \ \ r = _THUNK_GEN_DISPATCH(_name, env, __VA_ARGS__); \ - free(env); \ \ return r; \ } \ @@ -538,7 +537,6 @@ struct thunk_t { assert(env); \ \ r = _THUNK_GEN_DISPATCH(_name, env, __VA_ARGS__); \ - free(env); \ \ return r; \ } \ @@ -664,6 +662,21 @@ struct thunk_t { * including any payload if THUNK_ALLOC() was used. */ static inline int thunk_dispatch(thunk_t *thunk) { + int r; + + r = thunk->dispatch(thunk); + free(thunk); + + return r; +} + +/* Same as thunk_dispatch() but without the free. + * Callers can trivially free thunk instances w/free(), there's + * no fancy destructor stuff or anything. So when a thunk needs + * to be used repeatedly in a loop for instance, use this, then + * just free the thunk yourself. + */ +static inline int thunk_dispatch_keep(thunk_t *thunk) { return thunk->dispatch(thunk); } |