xml_prepend: Inserting elements

Previous: xml_write: Writing XML data to disk ] [ Top: index ] [ Next: xml_append: Inserting elements ]

Prepending to a linked list is, of course, very easy.
 
void xml_prepend (XML * parent, XML * child)
{
   ELEMENTLIST * list;

   child->parent = parent;

   list = (ELEMENTLIST *) malloc (sizeof(struct _list));
   list->element = child;
   list->prev = NULL;
   list->next = parent->children;
   parent->children = list;
}
Previous: xml_write: Writing XML data to disk ] [ Top: index ] [ Next: xml_append: Inserting elements ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was created using LPML.