mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-14 14:28:17 +02:00
SVG: use xmlOutputBuffer for file creation, instead of dumping xml tree in a memory buffer.
This commit is contained in:
parent
5d89faf6b3
commit
2af29f720f
1 changed files with 17 additions and 6 deletions
|
|
@ -1342,21 +1342,32 @@ _cairo_svg_document_destroy (cairo_svg_document_t *document)
|
||||||
free (document);
|
free (document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_cairo_svg_document_write (cairo_output_stream_t *output_stream,
|
||||||
|
const char * buffer,
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
if (_cairo_output_stream_write (output_stream, buffer, len) != CAIRO_STATUS_SUCCESS)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static cairo_status_t
|
static cairo_status_t
|
||||||
_cairo_svg_document_finish (cairo_svg_document_t *document)
|
_cairo_svg_document_finish (cairo_svg_document_t *document)
|
||||||
{
|
{
|
||||||
cairo_status_t status;
|
cairo_status_t status;
|
||||||
cairo_output_stream_t *output = document->output_stream;
|
cairo_output_stream_t *output = document->output_stream;
|
||||||
xmlChar *xml_buffer;
|
xmlOutputBufferPtr xml_output_buffer;
|
||||||
int xml_buffer_size;
|
|
||||||
|
|
||||||
if (document->finished)
|
if (document->finished)
|
||||||
return CAIRO_STATUS_SUCCESS;
|
return CAIRO_STATUS_SUCCESS;
|
||||||
|
|
||||||
/* FIXME: Dumping xml tree in memory is silly. */
|
xml_output_buffer = xmlOutputBufferCreateIO ((xmlOutputWriteCallback) _cairo_svg_document_write,
|
||||||
xmlDocDumpFormatMemoryEnc (document->xml_doc, &xml_buffer, &xml_buffer_size, "UTF-8", 1);
|
(xmlOutputCloseCallback) NULL,
|
||||||
_cairo_output_stream_write (document->output_stream, xml_buffer, xml_buffer_size);
|
(void *) document->output_stream,
|
||||||
xmlFree(xml_buffer);
|
NULL);
|
||||||
|
xmlSaveFormatFileTo (xml_output_buffer, document->xml_doc, "UTF-8", 1);
|
||||||
|
|
||||||
xmlFreeDoc (document->xml_doc);
|
xmlFreeDoc (document->xml_doc);
|
||||||
|
|
||||||
status = _cairo_output_stream_get_status (output);
|
status = _cairo_output_stream_get_status (output);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue