ref: 4e09200f7e4bf8791c9c720922734e0759206b72
dir: /libxml/xmlcomment.c/
#include <u.h>
#include <libc.h>
#include "xml.h"
Elem *
xmlcomment(Xml *xp, Elem **root, Elem *parent, char *comment)
{
Elem *ep, *t;
ep = xmlcalloc(xp, sizeof(Elem), 1);
if (!ep)
sysfatal("no memory - %r");
if (! *root)
*root = ep;
else {
for (t = *root; t->next; t = t->next)
continue;
t->next = ep;
}
ep->ns = nil;
ep->parent = parent;
ep->name = nil;
if (comment) {
ep->pcdata = xmlstrdup(xp, comment, 0);
if (!ep->pcdata)
sysfatal("no memory - %r");
}
return ep;
}