Ejemplo n.º 1
0
/****f* xml_element/xml_elem_free_non_recurse
 * NAME
 *   xml_elem_free_non_recurse
 * SYNOPSIS
 *   void xml_elem_free_non_recurse(xml_element* root)
 * FUNCTION
 *   free a single xml element.  child elements will not be freed.
 * INPUTS
 *   root - the element to free
 * RESULT
 *   void
 * NOTES
 * SEE ALSO
 *   xml_elem_free ()
 *   xml_elem_new ()
 * SOURCE
 */
void xml_elem_free_non_recurse(xml_element* root) {
   if(root) {
      xml_element_attr* attrs = Q_Head(&root->attrs);
      while(attrs) {
         my_free(attrs->key);
         my_free(attrs->val);
         my_free(attrs);
         attrs = Q_Next(&root->attrs);
      }

      Q_Destroy(&root->children);
      Q_Destroy(&root->attrs);
      if(root->name) {
          free((char *)root->name);
          root->name = NULL;
      }
      simplestring_free(&root->text);
      my_free(root);
   }
}
Ejemplo n.º 2
0
/****f* xml_element/xml_elem_free_non_recurse
 * NAME
 *   xml_elem_free_non_recurse
 * SYNOPSIS
 *   void xml_elem_free_non_recurse(xml_element* root)
 * FUNCTION
 *   free a single xml element.  child elements will not be freed.
 * INPUTS
 *   root - the element to free
 * RESULT
 *   void
 * NOTES
 * SEE ALSO
 *   xml_elem_free ()
 *   xml_elem_new ()
 * SOURCE
 */
void xml_elem_free_non_recurse(xml_element* root) {
   if(root) {
      xml_element_attr* attrs = Q_Head(&root->attrs);
      while(attrs) {
         my_free(attrs->key);
         my_free(attrs->val);
         my_free(attrs);
         attrs = Q_Next(&root->attrs);
      }

      Q_Destroy(&root->children);
      Q_Destroy(&root->attrs);
      // gcc-4.0 problem with:
      // my_free((char*)root->name);
      if(root->name) {
          char* p = (char*)root->name;
          my_free(p);
      }

      simplestring_free(&root->text);
      my_free(root);
   }
}