MCPcopy Create free account
hub / github.com/Kitware/VTK / htmlDocDumpMemoryFormat

Function htmlDocDumpMemoryFormat

ThirdParty/libxml2/vtklibxml2/HTMLtree.c:546–584  ·  view source on GitHub ↗

* htmlDocDumpMemoryFormat: * @cur: the document * @mem: OUT: the memory pointer * @size: OUT: the memory length * @format: should formatting spaces been added * * Dump an HTML document in memory and return the xmlChar * and it's size. * It's up to the caller to free the memory. */

Source from the content-addressed store, hash-verified

544 * It's up to the caller to free the memory.
545 */
546void
547htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
548 xmlOutputBufferPtr buf;
549 xmlCharEncodingHandlerPtr handler = NULL;
550 const char *encoding;
551
552 xmlInitParser();
553
554 if ((mem == NULL) || (size == NULL))
555 return;
556 *mem = NULL;
557 *size = 0;
558 if (cur == NULL)
559 return;
560
561 encoding = (const char *) htmlGetMetaEncoding(cur);
562 handler = htmlFindOutputEncoder(encoding);
563 buf = xmlAllocOutputBufferInternal(handler);
564 if (buf == NULL) {
565 xmlCharEncCloseFunc(handler);
566 return;
567 }
568
569 htmlDocContentDumpFormatOutput(buf, cur, NULL, format);
570
571 xmlOutputBufferFlush(buf);
572
573 if (!buf->error) {
574 if (buf->conv != NULL) {
575 *size = xmlBufUse(buf->conv);
576 *mem = xmlStrndup(xmlBufContent(buf->conv), *size);
577 } else {
578 *size = xmlBufUse(buf->buffer);
579 *mem = xmlStrndup(xmlBufContent(buf->buffer), *size);
580 }
581 }
582
583 xmlOutputBufferClose(buf);
584}
585
586/**
587 * htmlDocDumpMemory:

Callers 1

htmlDocDumpMemoryFunction · 0.85

Calls 11

xmlInitParserFunction · 0.85
htmlGetMetaEncodingFunction · 0.85
htmlFindOutputEncoderFunction · 0.85
xmlCharEncCloseFuncFunction · 0.85
xmlOutputBufferFlushFunction · 0.85
xmlBufUseFunction · 0.85
xmlStrndupFunction · 0.85
xmlBufContentFunction · 0.85
xmlOutputBufferCloseFunction · 0.85

Tested by

no test coverage detected