}
+/** Get a talloc_ctx which is valid only for this frame
+ *
+ * @param[in] request The current request.
+ * @return
+ * - a TALLOC_CTX which is valid only for this stack frame
+ */
+TALLOC_CTX *unlang_interpret_frame_talloc_ctx(REQUEST *request)
+{
+ unlang_stack_t *stack = request->stack;
+ unlang_stack_frame_t *frame = &stack->frame[stack->depth];
+
+ switch (frame->instruction->type) {
+ default:
+ break;
+
+ case UNLANG_TYPE_MODULE:
+ case UNLANG_TYPE_XLAT:
+ return (TALLOC_CTX *) frame->state;
+ }
+
+ /*
+ * Ensure that the memory is always cleaned up when the
+ * request exits. And make sure that this function is safe to call from anywhere.
+ */
+ return (TALLOC_CTX *) request;
+}
+
/** Get information about the interpreter state
*
* @ingroup xlat_functions
rlm_rcode_t unlang_interpret_stack_result(REQUEST *request);
+TALLOC_CTX *unlang_interpret_frame_talloc_ctx(REQUEST *request);
+
void unlang_interpret_init(void);
#ifdef __cplusplus
}
return UNLANG_ACTION_CALCULATE_RESULT;
}
-/** Yield a request back to the interpreter from within a module
- *
- * @param[in] request The current request.
- * @return
- * - a TALLOC_CTX which is valid only for this stack frame
- */
-TALLOC_CTX *unlang_module_frame_talloc_ctx(REQUEST *request)
-{
- unlang_stack_t *stack = request->stack;
- unlang_stack_frame_t *frame = &stack->frame[stack->depth];
-
- unlang_frame_state_module_t *state = talloc_get_type_abort(frame->state, unlang_frame_state_module_t);
-
- return (TALLOC_CTX *) state;
-}
-
void unlang_module_init(void)
{
unlang_register(UNLANG_TYPE_MODULE,
fr_unlang_module_resume_t resume,
fr_unlang_module_signal_t signal, void *rctx);
-TALLOC_CTX *unlang_module_frame_talloc_ctx(REQUEST *request);
-
#ifdef __cplusplus
}
#endif
/*
* Get frame-local talloc ctx
*/
- ctx = unlang_module_frame_talloc_ctx(request);
+ ctx = unlang_interpret_frame_talloc_ctx(request);
/*
* Do the asynchronous xlat expansion.