* xmlParserInputShrink: * @in: an XML parser input * * DEPRECATED: Don't use. * * This function removes used input for the parser. */
| 576 | * This function removes used input for the parser. |
| 577 | */ |
| 578 | void |
| 579 | xmlParserInputShrink(xmlParserInputPtr in) { |
| 580 | size_t used; |
| 581 | size_t ret; |
| 582 | |
| 583 | if (in == NULL) return; |
| 584 | if (in->buf == NULL) return; |
| 585 | if (in->base == NULL) return; |
| 586 | if (in->cur == NULL) return; |
| 587 | if (in->buf->buffer == NULL) return; |
| 588 | |
| 589 | used = in->cur - in->base; |
| 590 | /* |
| 591 | * Do not shrink on large buffers whose only a tiny fraction |
| 592 | * was consumed |
| 593 | */ |
| 594 | if (used > INPUT_CHUNK) { |
| 595 | ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN); |
| 596 | if (ret > 0) { |
| 597 | used -= ret; |
| 598 | if ((ret > ULONG_MAX) || |
| 599 | (in->consumed > ULONG_MAX - (unsigned long)ret)) |
| 600 | in->consumed = ULONG_MAX; |
| 601 | else |
| 602 | in->consumed += ret; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | if (xmlBufUse(in->buf->buffer) <= INPUT_CHUNK) { |
| 607 | xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK); |
| 608 | } |
| 609 | |
| 610 | in->base = xmlBufContent(in->buf->buffer); |
| 611 | if (in->base == NULL) { |
| 612 | /* TODO: raise error */ |
| 613 | in->base = BAD_CAST ""; |
| 614 | in->cur = in->base; |
| 615 | in->end = in->base; |
| 616 | return; |
| 617 | } |
| 618 | in->cur = in->base + used; |
| 619 | in->end = xmlBufEnd(in->buf->buffer); |
| 620 | } |
| 621 | |
| 622 | /************************************************************************ |
| 623 | * * |
nothing calls this directly
no test coverage detected