cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Doesn't fwrite() return the number of objects written, not the number of bytes?

From: Jamie Lokier <jamie_at_shareable.org>
Date: Thu, 30 Jul 2009 16:44:28 +0100

A. Craig West wrote:
> 2009/7/30 Jonathan Wallace <jwallace_at_livetechnology.com>:
> > That does seem to be a fundamental flaw with the callback.  curl is 20 years
> > old I guess when it was created, files that large didn't exist.  You are
> > correct about fwrite though, it returns the number of elements, not bytes.
>
> Generally I write my fwrite calls to write n elements of 1 byte in
> length, so that it will return the number of bytes written. This is
> indeed a problem if you ever need to write more than 4 GB of data in
> one transaction, and size_t has a 32 bit definition. I can't think of
> any use case, particularly with curl, where this would be necessary,
> though.

Note that write() also uses size_t for it's length argument and
ssize_t for it's result. The problem is not unique to fwrite().

-- Jamie
Received on 2009-07-30