]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Better initialisation
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 15 Mar 2021 20:20:58 +0000 (20:20 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 15 Mar 2021 20:20:58 +0000 (20:20 +0000)
src/lib/unlang/xlat_builtin.c

index 12b0f48c92153fb277a3c37a323189c9c3e26b26..0197df9e6cdd9d14e5b44818c2f514a08e12d10a 100644 (file)
@@ -350,15 +350,17 @@ xlat_t const *xlat_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func,
        /*
         *      Doesn't exist.  Create it.
         */
-       c = talloc_zero(ctx, xlat_t);
-       c->name = talloc_typed_strdup(c, name);
+       c = talloc(ctx, xlat_t);
+       *c = (xlat_t){
+               .name = talloc_typed_strdup(c, name),
+               .func = {
+                       .async = func
+               },
+               .type = XLAT_FUNC_NORMAL,
+               .needs_async = needs_async,             /* this function may yield */
+               .input_type = XLAT_INPUT_UNPROCESSED    /* set default - will be overridden if args are registered */
+       };
        talloc_set_destructor(c, _xlat_func_talloc_free);
-
-       c->func.async = func;
-       c->type = XLAT_FUNC_NORMAL;
-       c->needs_async = needs_async;   /* this function may yield */
-       c->input_type = XLAT_INPUT_UNPROCESSED; /* set default - will be overridden if args are registered */
-
        DEBUG3("%s: %s", __FUNCTION__, c->name);
 
        if (!rbtree_insert(xlat_root, c)) {