return((char **) NULL);
}
-MagickExport XMLTreeInfo *DestroyXMLTree(XMLTreeInfo *xml_info)
+static void DestroyXMLTreeRoot(XMLTreeInfo *xml_info)
{
char
**attributes;
assert((xml_info->signature == MagickSignature) ||
(((XMLTreeRoot *) xml_info)->signature == MagickSignature));
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- if (xml_info->child != (XMLTreeInfo *) NULL)
- xml_info->child=DestroyXMLTree(xml_info->child);
- if (xml_info->ordered != (XMLTreeInfo *) NULL)
- xml_info->ordered=DestroyXMLTree(xml_info->ordered);
if (xml_info->parent == (XMLTreeInfo *) NULL)
+ return;
+ /*
+ Free root tag allocations.
+ */
+ return;
+ root=(XMLTreeRoot *) xml_info;
+ for (i=NumberPredefinedEntities; root->entities[i]; i+=2)
+ root->entities[i+1]=DestroyString(root->entities[i+1]);
+ root->entities=(char **) RelinquishMagickMemory(root->entities);
+ for (i=0; root->attributes[i] != (char **) NULL; i++)
+ {
+ attributes=root->attributes[i];
+ if (attributes[0] != (char *) NULL)
+ attributes[0]=DestroyString(attributes[0]);
+ for (j=1; attributes[j] != (char *) NULL; j+=3)
{
- /*
- Free root tag allocations.
- */
- root=(XMLTreeRoot *) xml_info;
- for (i=NumberPredefinedEntities; root->entities[i]; i+=2)
- root->entities[i+1]=DestroyString(root->entities[i+1]);
- root->entities=(char **) RelinquishMagickMemory(root->entities);
- for (i=0; root->attributes[i] != (char **) NULL; i++)
+ if (attributes[j] != (char *) NULL)
+ attributes[j]=DestroyString(attributes[j]);
+ if (attributes[j+1] != (char *) NULL)
+ attributes[j+1]=DestroyString(attributes[j+1]);
+ if (attributes[j+2] != (char *) NULL)
+ attributes[j+2]=DestroyString(attributes[j+2]);
+ }
+ attributes=(char **) RelinquishMagickMemory(attributes);
+ }
+ if (root->attributes[0] != (char **) NULL)
+ root->attributes=(char ***) RelinquishMagickMemory(root->attributes);
+ if (root->processing_instructions[0] != (char **) NULL)
+ {
+ for (i=0; root->processing_instructions[i] != (char **) NULL; i++)
{
- attributes=root->attributes[i];
- if (attributes[0] != (char *) NULL)
- attributes[0]=DestroyString(attributes[0]);
- for (j=1; attributes[j] != (char *) NULL; j+=3)
- {
- if (attributes[j] != (char *) NULL)
- attributes[j]=DestroyString(attributes[j]);
- if (attributes[j+1] != (char *) NULL)
- attributes[j+1]=DestroyString(attributes[j+1]);
- if (attributes[j+2] != (char *) NULL)
- attributes[j+2]=DestroyString(attributes[j+2]);
- }
- attributes=(char **) RelinquishMagickMemory(attributes);
+ for (j=0; root->processing_instructions[i][j] != (char *) NULL; j++)
+ root->processing_instructions[i][j]=DestroyString(
+ root->processing_instructions[i][j]);
+ root->processing_instructions[i][j+1]=DestroyString(
+ root->processing_instructions[i][j+1]);
+ root->processing_instructions[i]=(char **) RelinquishMagickMemory(
+ root->processing_instructions[i]);
}
- if (root->attributes[0] != (char **) NULL)
- root->attributes=(char ***) RelinquishMagickMemory(root->attributes);
- if (root->processing_instructions[0] != (char **) NULL)
- {
- for (i=0; root->processing_instructions[i] != (char **) NULL; i++)
- {
- for (j=0; root->processing_instructions[i][j] != (char *) NULL; j++)
- root->processing_instructions[i][j]=DestroyString(
- root->processing_instructions[i][j]);
- root->processing_instructions[i][j+1]=DestroyString(
- root->processing_instructions[i][j+1]);
- root->processing_instructions[i]=(char **) RelinquishMagickMemory(
- root->processing_instructions[i]);
- }
- root->processing_instructions=(char ***) RelinquishMagickMemory(
- root->processing_instructions);
- }
+ root->processing_instructions=(char ***) RelinquishMagickMemory(
+ root->processing_instructions);
}
+}
+
+MagickExport XMLTreeInfo *DestroyXMLTree(XMLTreeInfo *xml_info)
+{
+ char
+ **attributes;
+
+ register ssize_t
+ i;
+
+ ssize_t
+ j;
+
+ XMLTreeRoot
+ *root;
+
+ assert(xml_info != (XMLTreeInfo *) NULL);
+ assert((xml_info->signature == MagickSignature) ||
+ (((XMLTreeRoot *) xml_info)->signature == MagickSignature));
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
+ if (xml_info->child != (XMLTreeInfo *) NULL)
+ xml_info->child=DestroyXMLTree(xml_info->child);
+ if (xml_info->ordered != (XMLTreeInfo *) NULL)
+ xml_info->ordered=DestroyXMLTree(xml_info->ordered);
+ DestroyXMLTreeRoot(xml_info);
xml_info->attributes=DestroyXMLTreeAttributes(xml_info->attributes);
xml_info->content=DestroyString(xml_info->content);
xml_info->tag=DestroyString(xml_info->tag);
*node,
*previous;
+ DestroyXMLTreeRoot(xml_info);
child->ordered=(XMLTreeInfo *) NULL;
child->sibling=(XMLTreeInfo *) NULL;
child->next=(XMLTreeInfo *) NULL;
xml_info->attributes[1]=ConstantString("");
}
if (xml_info->attributes == (char **) NULL)
- ThrowFatalException(ResourceLimitFatalError,
- "UnableToAcquireString");
+ ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
xml_info->attributes[i]=ConstantString(tag);
xml_info->attributes[i+2]=(char *) NULL;
(void) strlen(xml_info->attributes[i+1]);
xml_info->attributes[i]=DestroyString(xml_info->attributes[i]);
(void) CopyMagickMemory(xml_info->attributes+i,xml_info->attributes+i+2,
(size_t) (j-i)*sizeof(*xml_info->attributes));
- j-=2;
xml_info->attributes=(char **) ResizeQuantumMemory(xml_info->attributes,
(size_t) (j+2),sizeof(*xml_info->attributes));
if (xml_info->attributes == (char **) NULL)
ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
+ j-=2;
(void) CopyMagickMemory(xml_info->attributes[j+1]+(i/2),
- xml_info->attributes[j+1]+(i/2)+1,(size_t) ((j/2)-(i/2))*
+ xml_info->attributes[j+1]+(i/2)+1,(size_t) (((j+2)/2)-(i/2))*
sizeof(*xml_info->attributes));
return(xml_info);
}