Try to fix attribute removal semantics. We were leaking like a sieve here and

could not even remove namespaced attributes.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34641 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Niels Grewe 2012-01-26 21:54:28 +00:00
parent ae94271e12
commit 198cc1a46f
2 changed files with 27 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2012-01-26 22:48-CET Niels Grewe <niels.grewe@halbordnung.de>
* Source/NSXMLElement.m: Try to fix attribute removal semantics.
2012-01-26 22:28-CET Niels Grewe <niels.grewe@halbordnung.de>
* Source/NSXMLElement.m: Fix behaviour of -addAttribute:. Implement

View file

@ -174,7 +174,29 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
- (void) removeAttributeForName: (NSString*)name
{
xmlNodePtr node = (xmlNodePtr)(internal->node);
xmlUnsetProp(node,(xmlChar *)[name UTF8String]);
xmlAttrPtr attr = xmlHasProp(node, (xmlChar *)[name UTF8String]);
xmlAttrPtr newAttr = NULL;
NSXMLNode *attrNode = nil;
if (NULL == attr)
{
return;
}
// We need a copy of the node because xmlRemoveProp() frees attr:
newAttr = xmlCopyProp(NULL, attr);
attrNode = [NSXMLNode _objectForNode: (xmlNodePtr)attr];
// This is supposed to return failure for DTD defined attributes
if (0 == xmlRemoveProp(attr))
{
[attrNode _setNode: newAttr];
[self _removeSubNode: attrNode];
}
else
{
// In this case we throw away our copy again.
xmlFreeProp(newAttr);
}
}
- (void) setAttributes: (NSArray*)attributes