From: Arran Cudbard-Bell Date: Sun, 5 May 2019 21:11:29 +0000 (-0400) Subject: Add function for copying one pair's value to another pair X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f35b2356e18f28b27ff02e5041b99231a9a3fab9;p=thirdparty%2Ffreeradius-server.git Add function for copying one pair's value to another pair --- diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index faf4d1f4613..5b6c368871d 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -2041,6 +2041,19 @@ void fr_pair_list_move(VALUE_PAIR **to, VALUE_PAIR **from) fr_pair_add(to, head_new); } +/** Copy the value from one pair to another + * + * @param[out] out where to copy the value to. + * will clear assigned value. + * @param[in] in where to copy the value from + * Must have an assigned value. + */ +void fr_pair_value_copy(VALUE_PAIR *out, VALUE_PAIR *in) +{ + if (!fr_cond_assert(in->data.type != FR_TYPE_INVALID)) return; + if (out->data.type != FR_TYPE_INVALID) fr_value_box_clear(&out->data); + fr_value_box_copy(out, &out->data, &in->data); +} /** Convert string value to native attribute value * diff --git a/src/lib/util/pair.h b/src/lib/util/pair.h index ce7fd490041..7ffb9c8f3c9 100644 --- a/src/lib/util/pair.h +++ b/src/lib/util/pair.h @@ -304,6 +304,7 @@ int fr_pair_list_copy_by_ancestor(TALLOC_CTX *ctx, VALUE_PAIR **to, void fr_pair_list_move(VALUE_PAIR **to, VALUE_PAIR **from); /* Value manipulation */ +void fr_pair_value_copy(VALUE_PAIR *out, VALUE_PAIR *in); int fr_pair_value_from_str(VALUE_PAIR *vp, char const *value, ssize_t len, char quote, bool tainted); void fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t len); void fr_pair_value_memsteal(VALUE_PAIR *vp, uint8_t const *src);