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

Function xmlParserShrink

ThirdParty/libxml2/vtklibxml2/parserInternals.c:535–568  ·  view source on GitHub ↗

* xmlParserShrink: * @ctxt: an XML parser context * * Shrink the input buffer. */

Source from the content-addressed store, hash-verified

533 * Shrink the input buffer.
534 */
535void
536xmlParserShrink(xmlParserCtxtPtr ctxt) {
537 xmlParserInputPtr in = ctxt->input;
538 xmlParserInputBufferPtr buf = in->buf;
539 size_t used;
540
541 if (buf == NULL)
542 return;
543 /* Don't shrink pull parser memory buffers. */
544 if ((!PARSER_PROGRESSIVE(ctxt)) &&
545 (buf->encoder == NULL) &&
546 (buf->readcallback == NULL))
547 return;
548
549 used = in->cur - in->base;
550 /*
551 * Do not shrink on large buffers whose only a tiny fraction
552 * was consumed
553 */
554 if (used > INPUT_CHUNK) {
555 size_t res = xmlBufShrink(buf->buffer, used - LINE_LEN);
556
557 if (res > 0) {
558 used -= res;
559 if ((res > ULONG_MAX) ||
560 (in->consumed > ULONG_MAX - (unsigned long)res))
561 in->consumed = ULONG_MAX;
562 else
563 in->consumed += res;
564 }
565 }
566
567 xmlBufUpdateInput(buf->buffer, in, used);
568}
569
570/**
571 * xmlParserInputShrink:

Callers 3

xmlPopPEFunction · 0.85
parser.cFile · 0.85
xmlCtxtParseContentFunction · 0.85

Calls 2

xmlBufShrinkFunction · 0.85
xmlBufUpdateInputFunction · 0.85

Tested by

no test coverage detected