From: Alan T. DeKok Date: Sun, 1 Oct 2023 14:20:33 +0000 (-0400) Subject: don't copy arguments, just talloc_steal() them X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0beba5d5907b13421a45fbcabd81c5e0aff2600;p=thirdparty%2Ffreeradius-server.git don't copy arguments, just talloc_steal() them because copying could require lots of memory allocations. So even if talloc_steal() is inefficient, it's likely not much worse than allocating and copying entire data structures --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index f890e92ab16..63dabfef499 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -2300,14 +2300,8 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf MEM(arg = xlat_exp_alloc(head, XLAT_GROUP, vpt->name, strlen(vpt->name))); - /* - * This is less efficient than just stealing the - * xlat into the context of the new node... - * - * But talloc_steal can be extremely inefficient O(N) - * where N is chunk siblings. - */ - xlat_copy(arg->group, arg->group, xlat); + talloc_steal(arg->group, xlat); + arg->group = xlat; arg->quote = quote; arg->flags = xlat->flags;