by doing some sneaky overlaps of data structures.
static void pair_mutable(fr_pair_t *vp)
{
if (fr_type_is_leaf(vp->vp_type)) {
- vp->data.immutable = false;
+ vp->vp_immutable = false;
return;
}
for (vp = tmpl_dcursor_init(NULL, NULL, &cc, &cursor, request, vpt);
vp;
vp = fr_dcursor_next(&cursor)) {
- if (fr_type_is_leaf(vp->vp_type)) fr_value_box_set_immutable(&vp->data);
+ fr_pair_set_immutable(vp);
}
tmpl_dcursor_clear(&cc);
REXDENT();
* This hack allows the majority of the fr_pair_list_t to overlap with the
* fr_value_box_t which gives us much greater packing efficiency.
*/
- uint8_t pad[offsetof(fr_value_box_t, type) + sizeof(fr_type_t)];
+ uint8_t pad[offsetof(fr_value_box_t, safe_for)];
fr_pair_list_t children; //!< Nested attributes of this pair.
};
static inline CC_HINT(nonnull, always_inline)
void fr_pair_set_immutable(fr_pair_t *vp)
{
- fr_assert(fr_type_is_leaf(vp->vp_type));
-
- fr_value_box_set_immutable(&vp->data);
+ vp->vp_immutable = true;
}
static inline CC_HINT(nonnull, always_inline)
void fr_pair_clear_immutable(fr_pair_t *vp)
{
- fr_assert(fr_type_is_leaf(vp->vp_type));
-
- fr_value_box_clear_immutable(&vp->data);
+ vp->vp_immutable = false;
}
* fr_type_t should be an enumeration of the values in this union.
*
* Don't change the order of the fields below without checking that the output of radsize doesn't change.
+ *
+ * The first few fields (before safe_for) are reused in the #fr_pair_t. This allows structural
+ * data types to have vp->vp_type, and to also use / set the various flags defined below. Do NOT
+ * change the order of the fields!
*/
struct value_box_s {
/** Type and flags should appear together for packing efficiency
box->secret = secret;
}
-static inline CC_HINT(nonnull, always_inline)
-void fr_value_box_set_immutable(fr_value_box_t *box)
-{
- box->immutable = true;
-}
-
-static inline CC_HINT(nonnull, always_inline)
-void fr_value_box_clear_immutable(fr_value_box_t *box)
-{
- box->immutable = false;
-}
-
-
/** @name Assign and manipulate binary-unsafe C strings
*
* @{