* xmlAllocOutputBufferInternal: * @encoder: the encoding converter or NULL * * Create a buffered parser output * * Returns the new parser output or NULL */
| 1435 | * Returns the new parser output or NULL |
| 1436 | */ |
| 1437 | xmlOutputBufferPtr |
| 1438 | xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) { |
| 1439 | xmlOutputBufferPtr ret; |
| 1440 | |
| 1441 | ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer)); |
| 1442 | if (ret == NULL) { |
| 1443 | return(NULL); |
| 1444 | } |
| 1445 | memset(ret, 0, sizeof(xmlOutputBuffer)); |
| 1446 | ret->buffer = xmlBufCreate(); |
| 1447 | if (ret->buffer == NULL) { |
| 1448 | xmlFree(ret); |
| 1449 | return(NULL); |
| 1450 | } |
| 1451 | |
| 1452 | |
| 1453 | /* |
| 1454 | * For conversion buffers we use the special IO handling |
| 1455 | */ |
| 1456 | xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO); |
| 1457 | |
| 1458 | ret->encoder = encoder; |
| 1459 | if (encoder != NULL) { |
| 1460 | ret->conv = xmlBufCreateSize(4000); |
| 1461 | if (ret->conv == NULL) { |
| 1462 | xmlBufFree(ret->buffer); |
| 1463 | xmlFree(ret); |
| 1464 | return(NULL); |
| 1465 | } |
| 1466 | |
| 1467 | /* |
| 1468 | * This call is designed to initiate the encoder state |
| 1469 | */ |
| 1470 | xmlCharEncOutput(ret, 1); |
| 1471 | } else |
| 1472 | ret->conv = NULL; |
| 1473 | ret->writecallback = NULL; |
| 1474 | ret->closecallback = NULL; |
| 1475 | ret->context = NULL; |
| 1476 | ret->written = 0; |
| 1477 | |
| 1478 | return(ret); |
| 1479 | } |
| 1480 | |
| 1481 | #endif /* LIBXML_OUTPUT_ENABLED */ |
| 1482 |
no test coverage detected