[cairo] SUMMARY of Implementing cairo_read_func_t/cairo_write_func_t properly

Bill Spitzak spitzak at gmail.com
Fri Mar 11 17:17:15 UTC 2016


On Wed, Mar 9, 2016 at 10:46 PM, Bernhard R. Fischer <bf at abenteuerland.at>
wrote:

>
> >>>>       if (unlikely (status)) {
> >>>> +        if ((int) status < 0) status = CAIRO_STATUS_READ_ERROR;
> >>>>         cairo_status_t *error = png_get_error_ptr (png);
> >>>>         if (*error == CAIRO_STATUS_SUCCESS)
> >>>>             *error = status;
> >>>
> >>> This would probably need to look more like:
> >>>
> >>>     status = png_closure->read_func (png_closure->closure, data, size);
> >>>     if (unlikely (status)) {
> >>>         cairo_status_t *error;
> >>>         if ((int) status < 0)
> >>>             status = CAIRO_STATUS_READ_ERROR;
> >>>         error = png_get_error_ptr (png);
> >>
> >>
> >> Why? It makes no difference.
> >>
> >
> > The variables have to be declared first before any statements (required
> by
> > older C compilers).
>
> I just inserted the 1-line "if ( )..." statement. Everything else is as
> it is in the current (1.14.6) cairo-png.c.
>

The problem is that you have to put the declaration of the "error" variable
before the statement. Annoying but Cairo is following these rules so that
it works with some rather old compilers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20160311/c3cff61d/attachment.html>


More information about the cairo mailing list