* xmlAllocParserInputBuffer: * @enc: the charset encoding if known (deprecated) * * Create a buffered parser input for progressive parsing. * * The encoding argument is deprecated and should be set to * XML_CHAR_ENCODING_NONE. The encoding can be changed with * xmlSwitchEncoding or xmlSwitchEncodingName later on. * * Returns the new parser input or NULL */
| 1344 | * Returns the new parser input or NULL |
| 1345 | */ |
| 1346 | xmlParserInputBufferPtr |
| 1347 | xmlAllocParserInputBuffer(xmlCharEncoding enc) { |
| 1348 | xmlParserInputBufferPtr ret; |
| 1349 | |
| 1350 | ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer)); |
| 1351 | if (ret == NULL) { |
| 1352 | return(NULL); |
| 1353 | } |
| 1354 | memset(ret, 0, sizeof(xmlParserInputBuffer)); |
| 1355 | ret->buffer = xmlBufCreateSize(2 * xmlDefaultBufferSize); |
| 1356 | if (ret->buffer == NULL) { |
| 1357 | xmlFree(ret); |
| 1358 | return(NULL); |
| 1359 | } |
| 1360 | xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT); |
| 1361 | if (enc != XML_CHAR_ENCODING_NONE) { |
| 1362 | if (xmlLookupCharEncodingHandler(enc, &ret->encoder) != 0) { |
| 1363 | /* We can't handle errors properly here. */ |
| 1364 | xmlFreeParserInputBuffer(ret); |
| 1365 | return(NULL); |
| 1366 | } |
| 1367 | } |
| 1368 | if (ret->encoder != NULL) |
| 1369 | ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize); |
| 1370 | else |
| 1371 | ret->raw = NULL; |
| 1372 | ret->readcallback = NULL; |
| 1373 | ret->closecallback = NULL; |
| 1374 | ret->context = NULL; |
| 1375 | ret->compressed = -1; |
| 1376 | ret->rawconsumed = 0; |
| 1377 | |
| 1378 | return(ret); |
| 1379 | } |
| 1380 | |
| 1381 | #ifdef LIBXML_OUTPUT_ENABLED |
| 1382 | /** |
no test coverage detected