@@ -213,8 +213,13 @@ lyd_diff_add(const struct lyd_node *node, enum lyd_diff_op op, const char *orig_
213213 }
214214
215215 /* duplicate the subtree (and connect to the diff if possible) */
216- LY_CHECK_RET (lyd_dup_single (node , (struct lyd_node_inner * )diff_parent ,
217- LYD_DUP_RECURSIVE | LYD_DUP_NO_META | LYD_DUP_WITH_PARENTS | LYD_DUP_WITH_FLAGS , & dup ));
216+ if (diff_parent ) {
217+ LY_CHECK_RET (lyd_dup_single_to_ctx (node , LYD_CTX (diff_parent ), (struct lyd_node_inner * )diff_parent ,
218+ LYD_DUP_RECURSIVE | LYD_DUP_NO_META | LYD_DUP_WITH_PARENTS | LYD_DUP_WITH_FLAGS , & dup ));
219+ } else {
220+ LY_CHECK_RET (lyd_dup_single (node , NULL ,
221+ LYD_DUP_RECURSIVE | LYD_DUP_NO_META | LYD_DUP_WITH_PARENTS | LYD_DUP_WITH_FLAGS , & dup ));
222+ }
218223
219224 /* find the first duplicated parent */
220225 if (!diff_parent ) {
@@ -648,13 +653,13 @@ lyd_diff_attrs(const struct lyd_node *first, const struct lyd_node *second, uint
648653 * @param[in] siblings Siblings to search in.
649654 * @param[in] target Target node to search for.
650655 * @param[in] defaults Whether to consider (or ignore) default values.
651- * @param[in,out] dup_inst_cache Duplicate instance cache.
656+ * @param[in,out] dup_inst_ht Duplicate instance cache.
652657 * @param[out] match Found match, NULL if no matching node found.
653658 * @return LY_ERR value.
654659 */
655660static LY_ERR
656661lyd_diff_find_match (const struct lyd_node * siblings , const struct lyd_node * target , ly_bool defaults ,
657- struct lyd_dup_inst * * dup_inst_cache , struct lyd_node * * match )
662+ struct hash_table * * dup_inst_ht , struct lyd_node * * match )
658663{
659664 LY_ERR r ;
660665
@@ -670,7 +675,7 @@ lyd_diff_find_match(const struct lyd_node *siblings, const struct lyd_node *targ
670675 }
671676
672677 /* update match as needed */
673- LY_CHECK_RET (lyd_dup_inst_next (match , siblings , dup_inst_cache ));
678+ LY_CHECK_RET (lyd_dup_inst_next (match , siblings , dup_inst_ht ));
674679
675680 if (* match && ((* match )-> flags & LYD_DEFAULT ) && !defaults ) {
676681 /* ignore default nodes */
@@ -728,7 +733,7 @@ lyd_diff_siblings_r(const struct lyd_node *first, const struct lyd_node *second,
728733 const struct lyd_node * iter_first , * iter_second ;
729734 struct lyd_node * match_second , * match_first ;
730735 struct lyd_diff_userord * userord = NULL , * userord_item ;
731- struct lyd_dup_inst * dup_inst_first = NULL , * dup_inst_second = NULL ;
736+ struct hash_table * dup_inst_first = NULL , * dup_inst_second = NULL ;
732737 LY_ARRAY_COUNT_TYPE u ;
733738 enum lyd_diff_op op ;
734739 const char * orig_default ;
@@ -1079,14 +1084,14 @@ lyd_diff_insert(struct lyd_node **first_node, struct lyd_node *parent_node, stru
10791084 */
10801085static LY_ERR
10811086lyd_diff_apply_r (struct lyd_node * * first_node , struct lyd_node * parent_node , const struct lyd_node * diff_node ,
1082- lyd_diff_cb diff_cb , void * cb_data , struct lyd_dup_inst * * dup_inst )
1087+ lyd_diff_cb diff_cb , void * cb_data , struct hash_table * * dup_inst )
10831088{
10841089 LY_ERR ret ;
10851090 struct lyd_node * match , * diff_child ;
10861091 const char * str_val , * meta_str ;
10871092 enum lyd_diff_op op ;
10881093 struct lyd_meta * meta ;
1089- struct lyd_dup_inst * child_dup_inst = NULL ;
1094+ struct hash_table * child_dup_inst = NULL ;
10901095 const struct ly_ctx * ctx = LYD_CTX (diff_node );
10911096
10921097 /* read all the valid attributes */
@@ -1242,7 +1247,7 @@ lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff, const
12421247 lyd_diff_cb diff_cb , void * cb_data )
12431248{
12441249 const struct lyd_node * root ;
1245- struct lyd_dup_inst * dup_inst = NULL ;
1250+ struct hash_table * dup_inst = NULL ;
12461251 LY_ERR ret = LY_SUCCESS ;
12471252
12481253 LY_LIST_FOR (diff , root ) {
@@ -1757,12 +1762,12 @@ lyd_diff_is_redundant(struct lyd_node *diff)
17571762 */
17581763static LY_ERR
17591764lyd_diff_merge_r (const struct lyd_node * src_diff , struct lyd_node * diff_parent , lyd_diff_cb diff_cb , void * cb_data ,
1760- struct lyd_dup_inst * * dup_inst , uint16_t options , struct lyd_node * * diff )
1765+ struct hash_table * * dup_inst , uint16_t options , struct lyd_node * * diff )
17611766{
17621767 LY_ERR ret = LY_SUCCESS ;
17631768 struct lyd_node * child , * diff_node = NULL ;
17641769 enum lyd_diff_op src_op , cur_op ;
1765- struct lyd_dup_inst * child_dup_inst = NULL ;
1770+ struct hash_table * child_dup_inst = NULL ;
17661771
17671772 /* get source node operation */
17681773 LY_CHECK_RET (lyd_diff_get_op (src_diff , & src_op ));
@@ -1868,7 +1873,7 @@ lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff, c
18681873 lyd_diff_cb diff_cb , void * cb_data , uint16_t options )
18691874{
18701875 const struct lyd_node * src_root ;
1871- struct lyd_dup_inst * dup_inst = NULL ;
1876+ struct hash_table * dup_inst = NULL ;
18721877 LY_ERR ret = LY_SUCCESS ;
18731878
18741879 LY_LIST_FOR (src_diff , src_root ) {
@@ -1891,7 +1896,7 @@ lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
18911896 lyd_diff_cb diff_cb , void * cb_data , uint16_t options )
18921897{
18931898 LY_ERR ret ;
1894- struct lyd_dup_inst * dup_inst = NULL ;
1899+ struct hash_table * dup_inst = NULL ;
18951900
18961901 if (!src_sibling ) {
18971902 return LY_SUCCESS ;
0 commit comments