1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

Make xmlStaticCopyNode non-recursive

This commit is contained in:
Nick Wellnhofer 2022-02-06 21:11:38 +01:00
parent aab584dc31
commit 7618a3b159

41
tree.c
View File

@ -4342,8 +4342,45 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
} }
ret->last = ret->children; ret->last = ret->children;
} else if ((node->children != NULL) && (extended != 2)) { } else if ((node->children != NULL) && (extended != 2)) {
ret->children = xmlStaticCopyNodeList(node->children, doc, ret); xmlNodePtr cur, insert;
UPDATE_LAST_CHILD_AND_PARENT(ret)
cur = node->children;
insert = ret;
while (cur != NULL) {
xmlNodePtr copy = xmlStaticCopyNode(cur, doc, insert, 2);
if (copy == NULL) {
xmlFreeNode(ret);
return(NULL);
}
if (insert->last == NULL) {
insert->children = copy;
} else {
copy->prev = insert->last;
insert->last->next = copy;
}
insert->last = copy;
if (cur->children != NULL) {
cur = cur->children;
insert = copy;
continue;
}
while (1) {
if (cur->next != NULL) {
cur = cur->next;
break;
}
cur = cur->parent;
insert = insert->parent;
if (cur == node) {
cur = NULL;
break;
}
}
}
} }
out: out: