[libxml2] Make xmlStaticCopyNode non-recursive
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Make xmlStaticCopyNode non-recursive
- Date: Sat, 2 Apr 2022 18:48:36 +0000 (UTC)
commit 7618a3b15947cd28a060bde24992f8a96256d7d4
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Sun Feb 6 21:11:38 2022 +0100
Make xmlStaticCopyNode non-recursive
tree.c | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/tree.c b/tree.c
index e4425f10..8077348a 100644
--- a/tree.c
+++ b/tree.c
@@ -4342,8 +4342,45 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
}
ret->last = ret->children;
} else if ((node->children != NULL) && (extended != 2)) {
- ret->children = xmlStaticCopyNodeList(node->children, doc, ret);
- UPDATE_LAST_CHILD_AND_PARENT(ret)
+ xmlNodePtr cur, insert;
+
+ 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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]