* xmlAllocOutputBuffer: * @encoder: the encoding converter or NULL * * Create a buffered parser output * * Returns the new parser output or NULL */
| 1388 | * Returns the new parser output or NULL |
| 1389 | */ |
| 1390 | xmlOutputBufferPtr |
| 1391 | xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) { |
| 1392 | xmlOutputBufferPtr ret; |
| 1393 | |
| 1394 | ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer)); |
| 1395 | if (ret == NULL) { |
| 1396 | return(NULL); |
| 1397 | } |
| 1398 | memset(ret, 0, sizeof(xmlOutputBuffer)); |
| 1399 | ret->buffer = xmlBufCreate(); |
| 1400 | if (ret->buffer == NULL) { |
| 1401 | xmlFree(ret); |
| 1402 | return(NULL); |
| 1403 | } |
| 1404 | xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO); |
| 1405 | |
| 1406 | ret->encoder = encoder; |
| 1407 | if (encoder != NULL) { |
| 1408 | ret->conv = xmlBufCreateSize(4000); |
| 1409 | if (ret->conv == NULL) { |
| 1410 | xmlBufFree(ret->buffer); |
| 1411 | xmlFree(ret); |
| 1412 | return(NULL); |
| 1413 | } |
| 1414 | |
| 1415 | /* |
| 1416 | * This call is designed to initiate the encoder state |
| 1417 | */ |
| 1418 | xmlCharEncOutput(ret, 1); |
| 1419 | } else |
| 1420 | ret->conv = NULL; |
| 1421 | ret->writecallback = NULL; |
| 1422 | ret->closecallback = NULL; |
| 1423 | ret->context = NULL; |
| 1424 | ret->written = 0; |
| 1425 | |
| 1426 | return(ret); |
| 1427 | } |
| 1428 | |
| 1429 | /** |
| 1430 | * xmlAllocOutputBufferInternal: |
no test coverage detected