[xml] xmlAddChild and xmlUnlinkNode



Hi.

It seems to me that xmlAddChild behaviour is kinda unexpected when you try to add a node that is altready linked to another document (or node of another type). If you don't xmlUnlinkNode before add call this results in node being referenced by both documents, so on free is will fail (libc crash for me).

It's fine of course to always do xmlUnlinkNode no matter what but what bothers me is that xmlAddChild has xmlSetTreeDoc() inside that's called if new parent document doesn't match new child's doc. So references are fixed for new node only with xmlSetTreeDoc but not for old document it seems.

Does it sound reasonable to add xmlUnlinkNode in xmlAddChild or I should always unlink manually?

Nikolay

Attachment: test.c
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]