mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-22 02:08:09 +02:00
Make _cairo_output_stream_destroy return the stream's status as a last gasp.
This commit is contained in:
parent
3a92ab69c8
commit
89e7d5d420
2 changed files with 26 additions and 14 deletions
|
|
@ -60,7 +60,7 @@ _cairo_output_stream_init (cairo_output_stream_t *stream,
|
|||
cairo_output_stream_write_func_t write_func,
|
||||
cairo_output_stream_close_func_t close_func);
|
||||
|
||||
cairo_private void
|
||||
cairo_private cairo_status_t
|
||||
_cairo_output_stream_fini (cairo_output_stream_t *stream);
|
||||
|
||||
|
||||
|
|
@ -86,10 +86,16 @@ _cairo_output_stream_create (cairo_write_func_t write_func,
|
|||
cairo_close_func_t close_func,
|
||||
void *closure);
|
||||
|
||||
cairo_private void
|
||||
/* Returns the final status value associated with this object, just
|
||||
* before its last gasp. This final status value will capture any
|
||||
* status failure returned by the stream's close_func as well. */
|
||||
cairo_private cairo_status_t
|
||||
_cairo_output_stream_close (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
/* Returns the final status value associated with this object, just
|
||||
* before its last gasp. This final status value will capture any
|
||||
* status failure returned by the stream's close_func as well. */
|
||||
cairo_private cairo_status_t
|
||||
_cairo_output_stream_destroy (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
|
|
|
|||
|
|
@ -57,13 +57,12 @@ _cairo_output_stream_init (cairo_output_stream_t *stream,
|
|||
stream->closed = FALSE;
|
||||
}
|
||||
|
||||
cairo_private void
|
||||
cairo_private cairo_status_t
|
||||
_cairo_output_stream_fini (cairo_output_stream_t *stream)
|
||||
{
|
||||
_cairo_output_stream_close (stream);
|
||||
return _cairo_output_stream_close (stream);
|
||||
}
|
||||
|
||||
|
||||
const cairo_output_stream_t cairo_output_stream_nil = {
|
||||
NULL, /* write_func */
|
||||
NULL, /* close_func */
|
||||
|
|
@ -130,37 +129,44 @@ _cairo_output_stream_create (cairo_write_func_t write_func,
|
|||
return &stream->base;
|
||||
}
|
||||
|
||||
void
|
||||
cairo_status_t
|
||||
_cairo_output_stream_close (cairo_output_stream_t *stream)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
if (stream->closed)
|
||||
return;
|
||||
return stream->status;
|
||||
|
||||
if (stream == &cairo_output_stream_nil ||
|
||||
stream == &cairo_output_stream_nil_write_error)
|
||||
{
|
||||
return;
|
||||
return stream->status;
|
||||
}
|
||||
|
||||
if (stream->close_func) {
|
||||
status = stream->close_func (stream);
|
||||
if (status)
|
||||
/* Don't overwrite a pre-existing status failure. */
|
||||
if (stream->status == CAIRO_STATUS_SUCCESS)
|
||||
stream->status = status;
|
||||
}
|
||||
|
||||
stream->closed = TRUE;
|
||||
|
||||
return stream->status;
|
||||
}
|
||||
|
||||
void
|
||||
cairo_status_t
|
||||
_cairo_output_stream_destroy (cairo_output_stream_t *stream)
|
||||
{
|
||||
if (stream == NULL)
|
||||
return;
|
||||
cairo_status_t status;
|
||||
|
||||
_cairo_output_stream_fini (stream);
|
||||
if (stream == NULL)
|
||||
return CAIRO_STATUS_NULL_POINTER;
|
||||
|
||||
status = _cairo_output_stream_fini (stream);
|
||||
free (stream);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue