* xmlParserInputBufferCreateStatic: * @mem: the memory input * @size: the length of the memory block * @enc: the charset encoding if known * * Create a buffered parser input for the progressive parsing for the input * from an immutable memory area. This will not copy the memory area to * the buffer, but the memory is expected to be available until the end of * the parsing, this is usefu
| 2755 | * Returns the new parser input or NULL |
| 2756 | */ |
| 2757 | xmlParserInputBufferPtr |
| 2758 | xmlParserInputBufferCreateStatic(const char *mem, int size, |
| 2759 | xmlCharEncoding enc) { |
| 2760 | xmlParserInputBufferPtr ret; |
| 2761 | |
| 2762 | if (size <= 0) return(NULL); |
| 2763 | if (mem == NULL) return(NULL); |
| 2764 | |
| 2765 | ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer)); |
| 2766 | if (ret == NULL) { |
| 2767 | xmlIOErrMemory("creating input buffer"); |
| 2768 | return(NULL); |
| 2769 | } |
| 2770 | memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer)); |
| 2771 | ret->buffer = xmlBufferCreateStatic((void *)mem, (size_t) size); |
| 2772 | if (ret->buffer == NULL) { |
| 2773 | xmlFree(ret); |
| 2774 | return(NULL); |
| 2775 | } |
| 2776 | ret->encoder = xmlGetCharEncodingHandler(enc); |
| 2777 | if (ret->encoder != NULL) |
| 2778 | ret->raw = xmlBufferCreateSize(2 * xmlDefaultBufferSize); |
| 2779 | else |
| 2780 | ret->raw = NULL; |
| 2781 | ret->compressed = -1; |
| 2782 | ret->context = (void *) mem; |
| 2783 | ret->readcallback = NULL; |
| 2784 | ret->closecallback = NULL; |
| 2785 | |
| 2786 | return(ret); |
| 2787 | } |
| 2788 | |
| 2789 | #ifdef LIBXML_OUTPUT_ENABLED |
| 2790 | /** |