[pacman-dev] [PATCH 3/3] Unify buffer size used across the library

Dan McGee dpmcgee at gmail.com
Wed Oct 26 19:53:17 EDT 2011

On Wed, Oct 26, 2011 at 6:16 PM, Dave Reisner <d at falconindy.com> wrote:
> On Wed, Oct 26, 2011 at 05:44:43PM -0500, Dan McGee wrote:
>> Define a single BUFFER_SIZE constant in util.h and use it everywhere.
>> This also prepares us for libarchive 3.0, where the
>> ARCHIVE_DEFAULT_BYTES_PER_BLOCK constant has been taken out to the
>> woodshed.
> Any particular reason we're not using BUFSIZ out of stdio.h if its
> available?

1. It is documented only as "this is the size the functions in stdio.h
use", not necessarily as "this is the buffer size user space
applications should use".
2. Finding that documentation is hard. [1]
3. Any particular reason to? At least on my system it is 8192, and I
guess I have no idea if that varies across systems.

So yeah, I don't know. I suppose I could be convinced, and we could
just ifdef a hardcoded value in there if BUFSIZ wasn't defined, but I
also don't know that if that value has any sort of real magic to it.


[1] The best I could find was
<http://www.delorie.com/gnu/docs/glibc/libc_226.html>, and even that
is glibc specific.
Sometimes people also use BUFSIZ as the allocation size of buffers
used for related purposes, such as strings used to receive a line of
input with fgets (see section 12.8 Character Input). There is no
particular reason to use BUFSIZ for this instead of any other integer,
except that it might lead to doing I/O in chunks of an efficient size.

More information about the pacman-dev mailing list