3 week bump.

--
Scott Cheloha

> On Jul 28, 2017, at 9:26 PM, Scott Cheloha <scottchel...@gmail.com> wrote:
> 
> Hi,
> 
> This bit from setvbuf(3):
> 
>     The size parameter may be given as zero to obtain
>     deferred optimal-size buffer allocation as usual. 
> 
> doesn't describe what's happening in setvbuf.c.  When size is 0,
> fp->_fb.base is allocated immediately:
> 
>        /*
>         * Find optimal I/O size for seek optimization.  This also returns
>         * a `tty flag' to suggest that we check isatty(fd), but we do not
>         * care since our caller told us how to buffer.
>         */
>        flags |= __swhatbuf(fp, &iosize, &ttyflag);
>        if (size == 0) {
>                buf = NULL;     /* force local allocation */
>                size = iosize;
>        }
> 
>        /* Allocate buffer if needed. */
>        if (buf == NULL) {                                                     
>  
>                if ((buf = malloc(size)) == NULL) {
>                        /*
>                         * Unable to honor user's request.  We will return
>                         * failure, but try again with file system size.
>                         */
>                        ret = EOF;
>                        if (size != iosize) {
>                                size = iosize;
>                                buf = malloc(size);
>                        }                                                      
>  
>                }
>                if (buf == NULL) {
>                        /* No luck; switch to unbuffered I/O. */
> 
> Allocation is not "deferred," unless I've misunderstood something.
> 
> Not sure whether it's important to mention that the allocation
> occurs immediately as opposed to whenever I/O is first attempted,
> so I've just pared the remark down.
> 
> --
> Scott Cheloha
> 
> Index: lib/libc/stdio/setvbuf.3
> ===================================================================
> RCS file: /cvs/src/lib/libc/stdio/setvbuf.3,v
> retrieving revision 1.4
> diff -u -p -r1.4 setvbuf.3
> --- lib/libc/stdio/setvbuf.3  26 Nov 2014 18:16:32 -0000      1.4
> +++ lib/libc/stdio/setvbuf.3  29 Jul 2017 02:21:49 -0000
> @@ -90,7 +90,7 @@ fully buffered
> The
> .Fa size
> parameter may be given as zero
> -to obtain deferred optimal-size buffer allocation as usual.
> +to obtain an optimal-size buffer allocation.
> If it is not zero, then except for unbuffered files, the
> .Fa buf
> argument should point to a buffer at least

Reply via email to