void osync_xmlfield_delete(OSyncXMLField *xmlfield) { OSyncXMLField *child = NULL; osync_assert(xmlfield); // unlink and free our children first // // if we unlink ourselves (and therefore all the children) // then osync_xmlfield_free() will leak, since it doesn't know children // // if we code free to know children, then, as it cycles through the // OSyncXMLField children, it won't know how to tell whether each // child's node needs to be freed, or whether it has been freed // at the top level node. // // really, it's just easier and safer with this inefficient method :-( // I tried doing it in _free() and couldn't get it to work well. - CDF // for (child = xmlfield->child; child; ) { OSyncXMLField *next = child->next; osync_xmlfield_unlink(child); osync_xmlfield_free(child); child = next; } osync_xmlfield_unlink(xmlfield); osync_xmlfield_free(xmlfield); }
void osync_xmlfield_delete(OSyncXMLField *xmlfield) { osync_assert(xmlfield); osync_xmlfield_unlink(xmlfield); osync_xmlfield_free(xmlfield); }
void osync_xmlfield_adopt_xmlfield_after_field(OSyncXMLField *xmlfield, OSyncXMLField *to_link) { osync_assert(xmlfield); osync_assert(to_link); osync_xmlfield_unlink(to_link); xmlDOMWrapAdoptNode(NULL, to_link->node->doc, to_link->node, xmlfield->node->doc, xmlfield->node, 0); xmlAddNextSibling(xmlfield->node, to_link->node); to_link->next = xmlfield->next; to_link->prev = xmlfield; if(xmlfield->next) xmlfield->next->prev = to_link; else ((OSyncXMLFormat *)xmlfield->node->doc->_private)->last_child = to_link; xmlfield->next = to_link; ((OSyncXMLFormat *)xmlfield->node->doc->_private)->child_count++; }