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

Re: [xml] xmlDocDumpMemory problem under Windows



What is this, the memory debug mailing list?

You don't say which version of libxml, but since the problem is only
manifested on Windows I'll take a guess that the problem is related to
the fact that you should use xmlFree not free. I know that on Unixen,
the xmlFree function just maps directly to free, I've no idea what
happens on Windows but it may not be so straightforward (for instance
HeapAlloc/HeapFree may be used).

Gary

Wang Jian wrote:

> Hello,
>
> The following program runs well under Linux, but SEGV at free() under
> Windows. After some debug, no clue is found.
>
> #include <stdlib.h>
> #include <libxml/tree.h>
>
> main()
> {
>     xmlDocPtr doc;
>     xmlNodePtr tree, subtree;
>     xmlChar *buffer;
>     int size;
>
>     doc = xmlNewDoc("1.0");
>     doc->children = xmlNewDocNode(doc, NULL, "spy", NULL);
>     xmlSetProp(doc->children, "version", "1.0");
>     tree = xmlNewChild(doc->children, NULL, "targetlist", NULL);
>     xmlSetProp(tree, "action", "add");
>     subtree = xmlNewChild(tree, NULL, "target", "210.82.190.9");
>     xmlSetProp(subtree, "type", "host");
>     subtree = xmlNewChild(tree, NULL, "target", "210.82.190.10");
>     xmlSetProp(subtree, "type", "host");
>     subtree = xmlNewChild(tree, NULL, "target", "210.82.190.11");
>     xmlSetProp(subtree, "type", "host");
>
>     xmlDocDumpMemory(doc, &buffer, &size);
>     printf("size is %d\n--%s--\n", size, buffer);
>     free(buffer);
> }
>
> --
>   lark
>
> _______________________________________________
> xml mailing list
> xml gnome org
> http://mail.gnome.org/mailman/listinfo/xml

--
Gary Pennington
Solaris Kernel Development,
Sun Microsystems
Gary Pennington sun com







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