return vp;
}
-/** Allocate a pooled object that can hold a fr_pair_t any unknown attributes and value buffer
- *
- * @param[in] ctx to allocate the pooled object in.
- * @param[in] da If unknown, will be duplicated.
- * @param[in] value_len The expected length of the buffer. +1 will be added if this
- * if a FR_TYPE_STRING attribute.
- */
-fr_pair_t *fr_pair_afrom_da_with_pool(TALLOC_CTX *ctx, fr_dict_attr_t const *da, size_t value_len)
-{
- fr_pair_t *vp;
-
- unsigned int headers = 1;
-
- /*
- * Dict attributes allocate extensions
- * contiguously, so we only need one
- * header even though there's a variable
- * length name buff.
- */
- if (da->flags.is_unknown) {
- headers++;
- value_len += talloc_array_length(da); /* accounts for all extensions */
- }
-
- switch (da->type) {
- case FR_TYPE_OCTETS:
- headers++;
- break;
-
- case FR_TYPE_STRING:
- headers++;
- value_len++;
- break;
-
- default:
- fr_strerror_printf("Pooled fr_pair_t can only be allocated for "
- "'string' and 'octets' types not '%s'",
- fr_type_to_str(da->type));
- return NULL;
-
- }
-
- vp = talloc_zero_pooled_object(ctx, fr_pair_t, headers, value_len);
- if (unlikely(!vp)) {
- fr_strerror_printf("Out of memory");
- return NULL;
- }
- talloc_set_destructor(vp, _fr_pair_free);
-
- pair_init_null(vp);
-
- /*
- * If we get passed an unknown da, we need to ensure that
- * it's parented by "vp".
- */
- if (da->flags.is_unknown) {
- fr_dict_attr_t const *unknown;
-
- unknown = fr_dict_unknown_copy(vp, da);
- da = unknown;
- }
-
- pair_init_from_da(vp, da);
-
- return vp;
-}
-
/** Re-initialise an attribute with a different da
*
* If the new da has a different type to the old da, we'll attempt to cast
/** @hidecallergraph */
fr_pair_t *fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da) CC_HINT(warn_unused_result) CC_HINT(nonnull(2));
-fr_pair_t *fr_pair_afrom_da_with_pool(TALLOC_CTX *ctx, fr_dict_attr_t const *da, size_t value_len)
- CC_HINT(warn_unused_result) CC_HINT(nonnull(2));
-
int fr_pair_reinit_from_da(fr_pair_list_t *list, fr_pair_t *vp, fr_dict_attr_t const *da)
CC_HINT(nonnull(2, 3));