/* -*- coding: utf-8 -*- */

#include <libxml/parser.h>
#include <string.h>

int main(void) {
  xmlNodePtr root_node, node;
  xmlDocPtr doc;
  const size_t len = 1024*1024;
  const char blah[] = "blah ";
  const size_t szBlah = sizeof(blah)-1;
  char buf[len+1];
  size_t i=0;
  /* xmlAttrPtr attr; */
  LIBXML_TEST_VERSION;
  doc = xmlNewDoc(BAD_CAST "1.0");
  root_node = xmlNewNode(NULL, BAD_CAST "root");
  xmlDocSetRootElement(doc, root_node);
  node = xmlNewChild(root_node, NULL, BAD_CAST "node", NULL);
  while(i<len-szBlah) {
    memcpy(buf+i, blah, szBlah);
    i+=szBlah;
  }
  buf[i] = 0;
  xmlNewProp(node, BAD_CAST "href", BAD_CAST buf);
  xmlSaveFormatFileEnc("/tmp/bad.xml", doc, "UTF-8", 1);
  xmlFreeDoc(doc);
  xmlCleanupParser();
  return (0);
}
