use clearPrivatePointers() in NSXMLDocument as well as NSXMLNode when copying

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34518 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Doug Simons 2012-01-14 02:43:18 +00:00
parent 990bd6274c
commit f6289a65a1
2 changed files with 16 additions and 13 deletions

View file

@ -32,6 +32,8 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
#import <Foundation/NSXMLParser.h>
extern void clearPrivatePointers(xmlNodePtr aNode);
// Private methods to manage libxml pointers...
@interface NSXMLNode (Private)
- (void *) _node;
@ -297,7 +299,7 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
if (index >= [self childCount])
{
[NSException raise: NSRangeException
format: @"index to large"];
format: @"index too large"];
}
child = [[self children] objectAtIndex: index];
@ -395,7 +397,8 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
{
NSXMLDocument *c = (NSXMLDocument*)[super copyWithZone: zone];
internal->node = (xmlDoc *)xmlCopyDoc(MY_DOC, 1); // copy recursively
#warning need to zero out all of the _private pointers in the copied xmlDoc
clearPrivatePointers(internal->node); // clear out all of the _private pointers in the entire tree
((xmlNodePtr)internal->node)->_private = c;
// [c setStandalone: MY_DOC->standalone];
// [c setChildren: MY_DOC->children];
//GSIVar(c, rootElement) = MY_DOC->rootElement;

View file

@ -29,6 +29,17 @@
#import "GSInternal.h"
GS_PRIVATE_INTERNAL(NSXMLNode)
void clearPrivatePointers(xmlNodePtr aNode)
{
if (!aNode)
return;
aNode->_private = NULL;
clearPrivatePointers(aNode->children);
clearPrivatePointers(aNode->next);
if (aNode->type == XML_ELEMENT_NODE)
clearPrivatePointers((xmlNodePtr)(aNode->properties));
}
// Private methods to manage libxml pointers...
@interface NSXMLNode (Private)
- (void *) _node;
@ -340,17 +351,6 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
return childrenArray;
}
static void clearPrivatePointers(xmlNodePtr aNode)
{
if (!aNode)
return;
aNode->_private = NULL;
clearPrivatePointers(aNode->children);
clearPrivatePointers(aNode->next);
if (aNode->type == XML_ELEMENT_NODE)
clearPrivatePointers((xmlNodePtr)(aNode->properties));
}
- (id) copyWithZone: (NSZone*)zone
{
id c = [[self class] allocWithZone: zone];