From: Arran Cudbard-Bell Date: Tue, 7 Feb 2023 23:34:08 +0000 (-0600) Subject: Finish documenting request_state_replace X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fc5e744ee88fcf665718f2e79090f9090554e98;p=thirdparty%2Ffreeradius-server.git Finish documenting request_state_replace --- diff --git a/src/lib/server/request.c b/src/lib/server/request.c index aaf0eb14df0..6b7d5f91641 100644 --- a/src/lib/server/request.c +++ b/src/lib/server/request.c @@ -544,13 +544,20 @@ request_t *_request_local_alloc(char const *file, int line, TALLOC_CTX *ctx, * * It's now a pair, and is stored in request->pair_root. * So it's wrong for anyone other than this function to play games with it. + * + * @param[in] request to replace the state of. + * @param[in] new state to assign to the request. + * May be NULL in which case a new state will + * be alloced and assigned. + * + * @return the fr_pair_t containing the old state list. */ -fr_pair_t *request_state_replace(request_t *request, fr_pair_t *state) +fr_pair_t *request_state_replace(request_t *request, fr_pair_t *new) { fr_pair_t *old = request->session_state_ctx; fr_assert(request->session_state_ctx != NULL); - fr_assert(request->session_state_ctx != state); + fr_assert(request->session_state_ctx != new); fr_pair_remove(&request->pair_root->children, old); @@ -558,11 +565,11 @@ fr_pair_t *request_state_replace(request_t *request, fr_pair_t *state) * Save (or delete) the existing state, and re-initialize * it with a brand new one. */ - if (!state) MEM(state = fr_pair_afrom_da(NULL, request_attr_state)); + if (!new) MEM(new = fr_pair_afrom_da(NULL, request_attr_state)); - request->session_state_ctx = state; + request->session_state_ctx = new; - fr_pair_append(&request->pair_root->children, state); + fr_pair_append(&request->pair_root->children, new); return old; }