]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't copy arguments, just talloc_steal() them
authorAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:20:33 +0000 (10:20 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:20:33 +0000 (10:20 -0400)
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

src/lib/unlang/xlat_expr.c

index f890e92ab16bb64aad1090498b5c3be12619b741..63dabfef49978e3ce4752717e05ab4c9d68ca555 100644 (file)
@@ -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;