fr_assert(node->fmt != fmt);
if (node->fmt) talloc_const_free(node->fmt);
- node->fmt = talloc_bstrndup(node, fmt, len);
+ MEM(node->fmt = talloc_bstrndup(node, fmt, len));
}
/** Set the format string for an xlat node, copying from a talloc'd buffer
talloc_const_free(node->fmt);
}
}
- node->fmt = talloc_typed_strdup_buffer(node, fmt);
+ MEM(node->fmt = talloc_typed_strdup_buffer(node, fmt));
}
/** Set the format string for an xlat node from a pre-existing buffer
* @param[in] node to set fmt for.
* @param[in] fmt talloced buffer to set as the fmt string.
*/
-void xlat_exp_set_name_buffer_shallow(xlat_exp_t *node, char const *fmt)
+void xlat_exp_set_name_shallow(xlat_exp_t *node, char const *fmt)
{
fr_assert(node->fmt != fmt);
group = xlat_exp_alloc(head->call.args, XLAT_GROUP, NULL, 0);
group->quote = T_BARE_WORD;
- xlat_exp_set_name_buffer_shallow(group, node->fmt); /* not entirely correct, but good enough for now */
+ xlat_exp_set_name_shallow(group, node->fmt); /* not entirely correct, but good enough for now */
group->flags = node->flags;
talloc_steal(group->group, node);
fr_assert(child->type == XLAT_TMPL);
fr_assert(tmpl_contains_attr(child->vpt));
- xlat_exp_set_name_buffer_shallow(node, child->vpt->name);
+ xlat_exp_set_name_shallow(node, child->vpt->name);
xlat_func_append_arg(node, child, false);
char *name;
MEM(xlat_aprint(node, &name, group, NULL) >= 0);
- xlat_exp_set_name_buffer_shallow(node, name);
+ xlat_exp_set_name_shallow(node, name);
}
node->group = group;
node->vpt = vpt;
node->quote = quote;
- xlat_exp_set_name_buffer_shallow(node, vpt->name);
+ xlat_exp_set_name_shallow(node, vpt->name);
node->flags.pure = !tmpl_contains_xlat(node->vpt);
node->flags.needs_resolving = tmpl_needs_resolving(node->vpt);
*/
node->vpt = vpt;
node->quote = quote;
- xlat_exp_set_name_buffer_shallow(node, vpt->name);
+ xlat_exp_set_name_shallow(node, vpt->name);
if (tmpl_is_data(node->vpt)) {
/*
#define xlat_exp_alloc(_ctx, _type, _in, _inlen) _xlat_exp_alloc(NDEBUG_LOCATION_EXP _ctx, _type, _in, _inlen)
void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len) CC_HINT(nonnull);
-void xlat_exp_set_name_buffer_shallow(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
+void xlat_exp_set_name_shallow(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
void xlat_exp_set_name_buffer(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
/*
if (node->data.type == FR_TYPE_STRING) {
node->quote = T_DOUBLE_QUOTED_STRING;
- xlat_exp_set_name_buffer_shallow(node, node->data.vb_strvalue);
+ xlat_exp_set_name_buffer(node, node->data.vb_strvalue); /* later changes can free strvalue */
} else {
char *name;
node->quote = T_BARE_WORD;
MEM(fr_value_box_aprint(node, &name, box, NULL) >= 0);
- xlat_exp_set_name_buffer_shallow(node, name);
+ xlat_exp_set_name_shallow(node, name);
}
talloc_free(box);
if (box.type == FR_TYPE_BOOL) box.enumv = attr_expr_bool_enum;
MEM(fr_value_box_aprint(node, &name, &box, NULL) >= 0);
- xlat_exp_set_name_buffer_shallow(node, name);
+ xlat_exp_set_name_shallow(node, name);
fr_value_box_copy(node, &node->data, &box);
*out = node;
if (!func) return -1;
xlat_exp_set_type(node, XLAT_VIRTUAL);
- xlat_exp_set_name_buffer_shallow(node, vpt->name);
+ xlat_exp_set_name_shallow(node, vpt->name);
XLAT_DEBUG("VIRTUAL <-- %pV",
fr_box_strvalue_len(vpt->name, vpt->len));
* this out in a later pass.
*/
xlat_exp_set_type(node, XLAT_VIRTUAL_UNRESOLVED);
- xlat_exp_set_name_buffer_shallow(node, vpt->name);
+ xlat_exp_set_name_shallow(node, vpt->name);
node->vpt = vpt;
node->flags.needs_resolving = true;
/*
*/
} else {
xlat_exp_set_type(node, XLAT_TMPL);
- xlat_exp_set_name_buffer_shallow(node, vpt->name);
+ xlat_exp_set_name_shallow(node, vpt->name);
node->vpt = vpt;
}
*/
{
int ret;
- char *fmt;
xlat_exp_t *node;
xlat_exp_head_t *child;
tmpl_rules_t my_rules;
return -1;
}
- MEM(fmt = talloc_bstrndup(node, fr_sbuff_current(&s_m), fr_sbuff_behind(&s_m)));
- xlat_exp_set_name_buffer_shallow(node, fmt);
- tmpl_set_name_shallow(node->vpt, T_BARE_WORD, fmt, fr_sbuff_behind(&s_m));
+ xlat_exp_set_name(node, fr_sbuff_current(&s_m), fr_sbuff_behind(&s_m));
+ tmpl_set_name_shallow(node->vpt, T_BARE_WORD, node->fmt, fr_sbuff_behind(&s_m));
tmpl_set_xlat(node->vpt, child);
xlat_exp_insert_tail(head, node);
*/
if (slen > 0) {
do_value_box:
- xlat_exp_set_name_buffer_shallow(node, str);
+ xlat_exp_set_name_shallow(node, str);
fr_value_box_strdup(node, &node->data, NULL, str, false);
fr_value_box_mark_safe_for(&node->data, t_rules->literals_safe_for);
node->flags.constant = true;
while (fr_sbuff_extend(&our_in)) {
xlat_exp_t *node = NULL;
fr_token_t quote;
- char *fmt;
size_t len;
fr_sbuff_set(&m, &our_in); /* Record start of argument */
value_parse_rules_single_quoted.escapes);
if (slen < 0) goto error;
- xlat_exp_set_name_buffer_shallow(child, str);
+ xlat_exp_set_name_shallow(child, str);
fr_value_box_strdup(child, &child->data, NULL, str, false);
fr_value_box_mark_safe_for(&child->data, arg->safe_for); /* Literal values are treated as implicitly safe */
child->flags.constant = true;
goto error;
}
- fmt = talloc_bstrndup(node, fr_sbuff_current(&m), fr_sbuff_behind(&m));
- xlat_exp_set_name_buffer_shallow(node, fmt);
+ xlat_exp_set_name(node, fr_sbuff_current(&m), fr_sbuff_behind(&m));
/*
* Assert that the parser has created things which are safe for the current argument.