@@ -28,7 +28,7 @@ static LY_ERR schema_diff_node_type_change(const struct lysc_type *type1, const
2828 enum lys_diff_changed_e parent_changed , struct lys_diff_changes_s * changes ,
2929 struct lys_diff_ext_changes_s * ext_changes , struct lys_diff_s * diff );
3030static LY_ERR schema_diff_ext_insts_change (const struct lysc_ext_instance * exts1 , const struct lysc_ext_instance * exts2 ,
31- enum lys_diff_changed_e parent_changed , struct lys_diff_ext_changes_s * ext_changes , struct lys_diff_s * diff );
31+ struct lys_diff_ext_changes_s * ext_changes , struct lys_diff_s * diff );
3232static LY_ERR schema_diff_nodes_change_r (const struct lysc_node * node1 , const struct lysc_node * node2 , struct lys_diff_s * diff );
3333
3434/**
@@ -381,8 +381,8 @@ schema_diff_add_ext_change(const struct lysc_ext_instance *ext_old, const struct
381381 /* fill new ext_change */
382382 ec -> ext_old = ext_old ;
383383 ec -> ext_new = ext_new ;
384- ec -> changes = calloc ( 1 , sizeof * ec -> changes ) ;
385- LY_CHECK_ERR_RET (! ec -> changes , LOGMEM ( NULL ), LY_EMEM ) ;
384+ ec -> changes . changes = NULL ;
385+ ec -> changes . count = 0 ;
386386
387387 * ext_change = ec ;
388388 return LY_SUCCESS ;
@@ -2910,8 +2910,8 @@ schema_diff_module_identities_change(const struct lysc_ident *idents1, const str
29102910 }
29112911
29122912 /* ext-instance */
2913- LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (idents1 [u ].exts , idents2 [v ].exts , LYS_CHANGED_IDENT ,
2914- & ident_change -> ext_changes , diff ), cleanup );
2913+ LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (idents1 [u ].exts , idents2 [v ].exts , & ident_change -> ext_changes ,
2914+ diff ), cleanup );
29152915
29162916 /* check whether any of the changes were NBC */
29172917 schema_diff_check_node_change_nbc (& ident_change -> changes , diff );
@@ -2969,8 +2969,7 @@ schema_diff_module_change(const struct lys_module *mod1, const struct lys_module
29692969 LY_CHECK_RET (schema_diff_module_identities_change (mod1 -> identities , mod2 -> identities , LYS_CHANGED_NONE , diff ));
29702970
29712971 /* ext-instance */
2972- LY_CHECK_RET (schema_diff_ext_insts_change (mod1 -> compiled -> exts , mod2 -> compiled -> exts , LYS_CHANGED_NONE ,
2973- & diff -> mod_ext_changes , diff ));
2972+ LY_CHECK_RET (schema_diff_ext_insts_change (mod1 -> compiled -> exts , mod2 -> compiled -> exts , & diff -> mod_ext_changes , diff ));
29742973
29752974 return LY_SUCCESS ;
29762975}
@@ -3032,8 +3031,7 @@ schema_diff_node_musts_change(const struct lysc_must *musts1, const struct lysc_
30323031 LYS_CHANGED_ERR_APP_TAG , changes ), cleanup );
30333032
30343033 /* ext-instance */
3035- LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (musts1 [u ].exts , musts2 [v ].exts , LYS_CHANGED_MUST ,
3036- ext_changes , diff ), cleanup );
3034+ LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (musts1 [u ].exts , musts2 [v ].exts , ext_changes , diff ), cleanup );
30373035 }
30383036
30393037 LY_ARRAY_FOR (musts2 , v ) {
@@ -3234,8 +3232,7 @@ schema_diff_node_whens_change(struct lysc_when **whens1, struct lysc_when **when
32343232 cleanup );
32353233
32363234 /* ext-instance */
3237- LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (whens1 [u ]-> exts , whens2 [v ]-> exts , LYS_CHANGED_WHEN ,
3238- ext_changes , diff ), cleanup );
3235+ LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (whens1 [u ]-> exts , whens2 [v ]-> exts , ext_changes , diff ), cleanup );
32393236 }
32403237
32413238 LY_ARRAY_FOR (whens2 , v ) {
@@ -3456,7 +3453,7 @@ schema_diff_node_type_range_change(const struct lysc_range *range1, const struct
34563453 changes ));
34573454
34583455 /* ext-instance */
3459- LY_CHECK_RET (schema_diff_ext_insts_change (range1 -> exts , range2 -> exts , LYS_CHANGED_TYPE , ext_changes , diff ));
3456+ LY_CHECK_RET (schema_diff_ext_insts_change (range1 -> exts , range2 -> exts , ext_changes , diff ));
34603457
34613458 return LY_SUCCESS ;
34623459}
@@ -3518,8 +3515,7 @@ schema_diff_node_type_patterns_change(struct lysc_pattern **patterns1, struct ly
35183515 LYS_CHANGED_ERR_APP_TAG , changes ), cleanup );
35193516
35203517 /* ext-instance */
3521- LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (patterns1 [u ]-> exts , patterns2 [v ]-> exts , LYS_CHANGED_PATTERN ,
3522- ext_changes , diff ), cleanup );
3518+ LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (patterns1 [u ]-> exts , patterns2 [v ]-> exts , ext_changes , diff ), cleanup );
35233519
35243520 /* inverted */
35253521 if (patterns1 [u ]-> inverted != patterns2 [v ]-> inverted ) {
@@ -3614,8 +3610,7 @@ schema_diff_node_type_bitenum_change(const struct lysc_type_bitenum_item *bitenu
36143610 /* if-features not supported */
36153611
36163612 /* ext-instance */
3617- LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (bitenums1 [u ].exts , bitenums2 [v ].exts ,
3618- parent_changed ? parent_changed : changed , ext_changes , diff ), cleanup );
3613+ LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (bitenums1 [u ].exts , bitenums2 [v ].exts , ext_changes , diff ), cleanup );
36193614
36203615 /* value/position, does not matter */
36213616 if (bitenums1 [u ].value != bitenums2 [v ].value ) {
@@ -3886,7 +3881,7 @@ schema_diff_node_type_change(const struct lysc_type *type1, const struct lysc_ty
38863881 }
38873882
38883883 /* ext-instance */
3889- LY_CHECK_RET (schema_diff_ext_insts_change (type1 -> exts , type2 -> exts , LYS_CHANGED_TYPE , ext_changes , diff ));
3884+ LY_CHECK_RET (schema_diff_ext_insts_change (type1 -> exts , type2 -> exts , ext_changes , diff ));
38903885
38913886 return LY_SUCCESS ;
38923887}
@@ -4027,7 +4022,7 @@ schema_diff_node_change(const struct lysc_node *node1, const struct lysc_node *n
40274022 }
40284023
40294024 /* ext-instance */
4030- LY_CHECK_RET (schema_diff_ext_insts_change (node1 -> exts , node2 -> exts , LYS_CHANGED_NONE , ext_changes , diff ));
4025+ LY_CHECK_RET (schema_diff_ext_insts_change (node1 -> exts , node2 -> exts , ext_changes , diff ));
40314026
40324027 return LY_SUCCESS ;
40334028}
@@ -4150,7 +4145,7 @@ schema_diff_ext_inst_substmts_change(const struct lysc_ext_substmt *substmts1, c
41504145 case LY_STMT_EXTENSION_INSTANCE :
41514146 /* ext-instance */
41524147 LY_CHECK_GOTO (rc = schema_diff_ext_insts_change (* (substmts1 [u ].storage_p ), * (substmts2 [v ].storage_p ),
4153- LYS_CHANGED_EXT_INST , ext_changes , diff ), cleanup );
4148+ ext_changes , diff ), cleanup );
41544149 break ;
41554150 case LY_STMT_FRACTION_DIGITS :
41564151 case LY_STMT_REQUIRE_INSTANCE :
@@ -4287,11 +4282,11 @@ schema_diff_ext_inst_substmts_change(const struct lysc_ext_substmt *substmts1, c
42874282 */
42884283static LY_ERR
42894284schema_diff_ext_insts_change (const struct lysc_ext_instance * exts1 , const struct lysc_ext_instance * exts2 ,
4290- enum lys_diff_changed_e parent_changed , struct lys_diff_ext_changes_s * ext_changes , struct lys_diff_s * diff )
4285+ struct lys_diff_ext_changes_s * ext_changes , struct lys_diff_s * diff )
42914286{
42924287 LY_ERR rc = LY_SUCCESS ;
42934288 ly_bool * exts2_found , found ;
4294- enum lys_diff_changed_e ext_parent_changed ;
4289+ enum lys_diff_changed_e parent_changed ;
42954290 struct lys_diff_ext_change_s * ext_change ;
42964291 LY_ARRAY_COUNT_TYPE u , v ;
42974292
@@ -4311,15 +4306,16 @@ schema_diff_ext_insts_change(const struct lysc_ext_instance *exts1, const struct
43114306
43124307 /* add new ext-instance to changes */
43134308 LY_CHECK_RET (schema_diff_add_ext_change (& exts1 [u ], found ? & exts2 [v ] : NULL , ext_changes , & ext_change ));
4309+ parent_changed = schema_diff_stmt2changed (exts1 [u ].parent_stmt );
43144310
43154311 if (!found ) {
43164312 /* removed */
43174313 if (schema_diff_has_bc_ext (exts1 [u ].exts )) {
43184314 LY_CHECK_GOTO (rc = schema_diff_add_change (LYS_CHANGE_REMOVED , parent_changed , LYS_CHANGED_EXT_INST , 0 ,
4319- ext_change -> changes ), cleanup );
4315+ & ext_change -> changes ), cleanup );
43204316 } else {
43214317 LY_CHECK_GOTO (rc = schema_diff_add_change (LYS_CHANGE_REMOVED , parent_changed , LYS_CHANGED_EXT_INST , 1 ,
4322- ext_change -> changes ), cleanup );
4318+ & ext_change -> changes ), cleanup );
43234319
43244320 /* NBC */
43254321 diff -> is_nbc = 1 ;
@@ -4328,12 +4324,11 @@ schema_diff_ext_insts_change(const struct lysc_ext_instance *exts1, const struct
43284324 }
43294325
43304326 /* substatements */
4331- ext_parent_changed = (parent_changed == LYS_CHANGED_NONE ) ? LYS_CHANGED_EXT_INST : parent_changed ;
4332- LY_CHECK_GOTO (rc = schema_diff_ext_inst_substmts_change (exts1 [u ].substmts , exts2 [v ].substmts , ext_parent_changed ,
4333- ext_change -> changes , ext_changes , diff ), cleanup );
4327+ LY_CHECK_GOTO (rc = schema_diff_ext_inst_substmts_change (exts1 [u ].substmts , exts2 [v ].substmts , parent_changed ,
4328+ & ext_change -> changes , ext_changes , diff ), cleanup );
43344329
43354330 /* check whether any of the changes were NBC */
4336- schema_diff_check_node_change_nbc (ext_change -> changes , diff );
4331+ schema_diff_check_node_change_nbc (& ext_change -> changes , diff );
43374332 }
43384333
43394334 LY_ARRAY_FOR (exts2 , v ) {
@@ -4343,10 +4338,11 @@ schema_diff_ext_insts_change(const struct lysc_ext_instance *exts1, const struct
43434338
43444339 /* add new ext-instance to changes */
43454340 LY_CHECK_RET (schema_diff_add_ext_change (NULL , & exts2 [v ], ext_changes , & ext_change ));
4341+ parent_changed = schema_diff_stmt2changed (exts2 [v ].parent_stmt );
43464342
43474343 /* added */
43484344 LY_CHECK_GOTO (rc = schema_diff_add_change (LYS_CHANGE_ADDED , parent_changed , LYS_CHANGED_EXT_INST , 0 ,
4349- ext_change -> changes ), cleanup );
4345+ & ext_change -> changes ), cleanup );
43504346 }
43514347
43524348cleanup :
@@ -4482,8 +4478,7 @@ lysc_diff_erase_ext_changes(struct lys_diff_ext_changes_s *ext_changes)
44824478 uint32_t i ;
44834479
44844480 for (i = 0 ; i < ext_changes -> count ; ++ i ) {
4485- free (ext_changes -> changes [i ].changes -> changes );
4486- free (ext_changes -> changes [i ].changes );
4481+ free (ext_changes -> changes [i ].changes .changes );
44874482 }
44884483 free (ext_changes -> changes );
44894484}
@@ -4495,6 +4490,7 @@ lysc_diff_erase(struct lys_diff_s *diff)
44954490
44964491 /* module */
44974492 free (diff -> module_changes .changes );
4493+ lysc_diff_erase_ext_changes (& diff -> mod_ext_changes );
44984494
44994495 for (i = 0 ; i < diff -> ident_change_count ; ++ i ) {
45004496 free (diff -> ident_changes [i ].changes .changes );
@@ -4528,8 +4524,6 @@ lysc_diff_erase(struct lys_diff_s *diff)
45284524 }
45294525 free (diff -> dev_changes );
45304526
4531- lysc_diff_erase_ext_changes (& diff -> mod_ext_changes );
4532-
45334527 /* parsed node */
45344528 for (i = 0 ; i < diff -> pnode_change_count ; ++ i ) {
45354529 free (diff -> pnode_changes [i ].changes .changes );
0 commit comments