Re: [Vala] patch to add read/write to FileStream



On Wed, Sep 10, 2008 at 12:31 PM, Jürg Billeter <j bitron ch> wrote:
On Thu, 2008-09-04 at 18:14 -0400, Cliff Brake wrote:
The below patch adds read/write to FileStream:

Thanks for the patch.

Question:  is there any way I can always set nmemb=1 so the caller
does not have to set that variable?  In vala, I would just do:

read(buf), instead of read(buf, 1)

We can support this using default arguments as Sam already responded,
however, why should we do this? If you only want to read or write one
byte, you can use the getc or putc methods.

the fread call looks like:

fread(void *ptr, size_t size, size_t nmemb, FILE *stream)

from what I can tell, Vala automatically fills in the size parameter
with the length of buf, so it will always try to read up to the length
of the buffer elements.  nmemb should always be one in this case
because we do not have control of the size argument.

Thanks,
Cliff

-- 
=======================
Cliff Brake
http://bec-systems.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]