@@ -1112,8 +1112,6 @@ ctx_modules_undo_backlinks(struct ly_ctx *ctx, struct ly_set *mods)
11121112 uint8_t j ;
11131113 unsigned int u , v ;
11141114 struct lys_module * mod ;
1115- struct lys_node * elem , * next ;
1116- struct lys_node_leaf * leaf ;
11171115
11181116 /* maintain backlinks (start with internal ietf-yang-library which have leafs as possible targets of leafrefs */
11191117 for (o = ctx -> internal_module_count - 1 ; o < ctx -> models .used ; o ++ ) {
@@ -1156,54 +1154,6 @@ ctx_modules_undo_backlinks(struct ly_ctx *ctx, struct ly_set *mods)
11561154 mod -> ident [u ].der = NULL ;
11571155 }
11581156 }
1159-
1160- /* 3) leafrefs */
1161- for (elem = next = mod -> data ; elem ; elem = next ) {
1162- if (elem -> nodetype & (LYS_LEAF | LYS_LEAFLIST )) {
1163- leaf = (struct lys_node_leaf * )elem ; /* shortcut */
1164- if (leaf -> backlinks ) {
1165- if (!mods ) {
1166- /* remove all backlinks */
1167- ly_set_free (leaf -> backlinks );
1168- leaf -> backlinks = NULL ;
1169- } else {
1170- for (v = 0 ; v < leaf -> backlinks -> number ; v ++ ) {
1171- if (ly_set_contains (mods , leaf -> backlinks -> set .s [v ]-> module ) != -1 ) {
1172- /* derived identity is in module to remove */
1173- ly_set_rm_index (leaf -> backlinks , v );
1174- v -- ;
1175- }
1176- }
1177- if (!leaf -> backlinks -> number ) {
1178- /* all backlinks removed */
1179- ly_set_free (leaf -> backlinks );
1180- leaf -> backlinks = NULL ;
1181- }
1182- }
1183- }
1184- }
1185-
1186- /* select next element to process */
1187- next = elem -> child ;
1188- /* child exception for leafs, leaflists, anyxml and groupings */
1189- if (elem -> nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA | LYS_GROUPING )) {
1190- next = NULL ;
1191- }
1192- if (!next ) {
1193- /* no children, try siblings */
1194- next = elem -> next ;
1195- }
1196- while (!next ) {
1197- /* parent is already processed, go to its sibling */
1198- elem = lys_parent (elem );
1199- if (!elem ) {
1200- /* we are done, no next element to process */
1201- break ;
1202- }
1203- /* no siblings, go back through parents */
1204- next = elem -> next ;
1205- }
1206- }
12071157 }
12081158}
12091159
@@ -1212,8 +1162,6 @@ ctx_modules_redo_backlinks(struct ly_set *mods)
12121162{
12131163 unsigned int i , j , k , s ;
12141164 struct lys_module * mod ;
1215- struct lys_node * next , * elem ;
1216- struct lys_type * type ;
12171165 struct lys_feature * feat ;
12181166
12191167 for (i = 0 ; i < mods -> number ; ++ i ) {
@@ -1241,49 +1189,6 @@ ctx_modules_redo_backlinks(struct ly_set *mods)
12411189 }
12421190 }
12431191 }
1244-
1245- /* leafrefs */
1246- LY_TREE_DFS_BEGIN (mod -> data , next , elem ) {
1247- if (elem -> nodetype == LYS_GROUPING ) {
1248- goto next_sibling ;
1249- }
1250-
1251- if (elem -> nodetype & (LYS_LEAF | LYS_LEAFLIST )) {
1252- type = & ((struct lys_node_leaf * )elem )-> type ; /* shortcut */
1253- if (type -> base == LY_TYPE_LEAFREF ) {
1254- lys_leaf_add_leafref_target (type -> info .lref .target , elem );
1255- }
1256- }
1257-
1258- /* select element for the next run - children first */
1259- next = elem -> child ;
1260-
1261- /* child exception for leafs, leaflists and anyxml without children */
1262- if (elem -> nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA )) {
1263- next = NULL ;
1264- }
1265- if (!next ) {
1266- next_sibling :
1267- /* no children */
1268- if (elem == mod -> data ) {
1269- /* we are done, (START) has no children */
1270- break ;
1271- }
1272- /* try siblings */
1273- next = elem -> next ;
1274- }
1275- while (!next ) {
1276- /* parent is already processed, go to its sibling */
1277- elem = lys_parent (elem );
1278-
1279- /* no siblings, go back through parents */
1280- if (lys_parent (elem ) == lys_parent (mod -> data )) {
1281- /* we are done, no next element to process */
1282- break ;
1283- }
1284- next = elem -> next ;
1285- }
1286- }
12871192 }
12881193
12891194 return 0 ;
@@ -1522,7 +1427,7 @@ lys_set_enabled(const struct lys_module *module)
15221427 ly_set_add (disabled , mod , 0 );
15231428 }
15241429
1525- /* maintain backlinks (start with internal ietf-yang-library which have leafs as possible targets of leafrefs */
1430+ /* maintain backlinks */
15261431 ctx_modules_redo_backlinks (mods );
15271432
15281433 /* re-apply the deviations and augments */
0 commit comments