fr_dlist_head_t interior;
fr_pair_t *src_vp;
+ if (dst) {
+ fr_pair_t *old;
+
+ DEBUG_OVERWRITE(dst, src_vp);
+ old = fr_dcursor_replace(&dst_list, fr_pair_copy(talloc_parent(dst), src_vp));
+ talloc_free(old); /* Remove the old pair */
+
+ goto op_set_done;
+ }
+
fr_dlist_talloc_init(&leaf, tmpl_attr_extent_t, entry);
fr_dlist_talloc_init(&interior, tmpl_attr_extent_t, entry);
goto op_set_error;
} else {
extent = fr_dlist_head(&leaf);
- if (dst) {
- DEBUG_OVERWRITE(dst, src_vp);
- dst = fr_dcursor_replace(extent->list, fr_pair_copy(extent->list_ctx, src_vp));
- talloc_free(dst);
- } else {
- fr_pair_append(extent->list, fr_pair_copy(extent->list_ctx, src_vp));
- }
+ fr_pair_append(extent->list, fr_pair_copy(extent->list_ctx, src_vp));
}
-
+ op_set_done:
/* Free any we didn't insert */
fr_pair_list_free(&src_list);
fr_assert(fr_dlist_num_elements(&interior) == 0);
* @param[in] vpt specifying the #fr_pair_t type to retrieve or create.
* Must be #TMPL_TYPE_ATTR.
* @return
+ * - 1 on success a pair was created.
* - 0 on success a pair was found.
* - -1 if a new #fr_pair_t couldn't be found or created.
* - -2 if list could not be found (doesn't exist in current #request_t).
if (vpt->type == TMPL_TYPE_LIST) {
do_list:
if (leaf) EXTENT_ADD(leaf, NULL, list_ctx, list_head);
- goto done;
+ return 0;
}
/*
continue;
default:
- if (leaf) EXTENT_ADD(leaf, NULL, list_ctx, list_head);
break;
}
}
-done:
- /*
- * If we were asked to provide interior
- * and leaf lists, and there's no result
- * in either, then that's a logic error.
- *
- * We either have an attribute or will
- * need to build out pairs to it.
- */
- fr_assert(!leaf || !interior || (fr_dlist_num_elements(leaf) > 0) || (fr_dlist_num_elements(interior) > 0));
-
return 0;
}