Re: [xml] xmlAddChil and xmlFreeDoc



Sorry, xmlAddChild freed doc_module so I don't have to do xmlFreeDoc after xmlAddChild?

Antonio Meilán García escribió:
Hello,
I have a question about xmlAddChild, here is the code:
 
    fd = open("FILE.xml", O_RDWR | O_CREAT );
    if (fd < 0)  perror("Error fd");

    doc=xmlReadFd(fd,  NULL, "UTF-8",0);
    if (doc==NULL) printf("doc==NULL\n");

    close(fd);
   
    root=xmlDocGetRootElement(doc);
   
    doc_module = xmlReadFile("OTHER_FILE.xml","UTF-8", 0);
    if (doc_module==NULL) printf("doc_module=NULL\n");

    root_module = xmlDocGetRootElement(doc_module);

    if (xmlAddChild(node,root_module)==NULL) printf("xmlAddChild problem\n");

    xmlFreeDoc(doc_modulo);

---------
  
    => In that point I get:
        *** glibc detected *** free(): invalid pointer: 0x0003ebb9 ***


If I don´t  locate xmlAddChild:
....
    root_module = xmlDocGetRootElement(doc_module);
    xmlFreeDoc(doc_modulo);

there are not problem and xmlFreeDoc doesn't break the program,

What is the problem with xmlAddChild? How can I do the root_module child of root and obviously free doc_module pointer?

Thanks for your help,
Antonio

_______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml gnome org http://mail.gnome.org/mailman/listinfo/xml



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