[cairo] Implementing cairo_read_func_t/cairo_write_func_t properly

Bill Spitzak spitzak at gmail.com
Mon Jan 4 10:24:36 PST 2016


On Sun, Jan 3, 2016 at 11:50 PM, Bernhard Fischer <bf at abenteuerland.at>
wrote:

> On Sunday 03 January 2016 14:29:57 Behdad Esfahbod wrote:
> > On 16-01-02 09:34 PM, Bill Spitzak wrote:
> > > On 01/02/2016 01:27 PM, Bernhard Fischer wrote:
> > >> On Saturday 02 January 2016 13:01:39 Bill Spitzak wrote:
> > >>> I think the api has to be changed to return number of bytes read,
> and a
> > >>> negative number for eof.
> > >>
> > >> The return value should be the number of bytes read and on eof it is
> > >> something between 0 and length. If it is called again at/after eof it
> > >> returns 0 again. A negative value (-1) is only returned in case of
> error
> > >> (but not EOF). This is exactly like read(3) behaves.
> > >
> > > Yes you are correct, I made a typo, I meant to say "error" where I
> wrote
> > > "eof". I fully agree with your description.
> >
> > Given that we cannot change the signature now, I suggest we hack it up to
> > interpret negative numbers returned from the callback to be interpreted
> as a
> > short read; the absolute value of the returned negative number is the
> > number of bytes read.
> >
> > Cairo itself won't need to be updated, but clients should be encouraged
> to
> > implement the new behaviour.
> >
> > b
>
>
> I agree, that is a backwards compatible solution.
>

I think you need to make negative number mean "it was this short". Ie if a
request to read 10 bytes only reads 8, it returns -2.

The reason is so that reading the entire block still returns
CAIRO_STATUS_SUCCESS.



>
> Bernhard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20160104/b8855459/attachment.html>


More information about the cairo mailing list