bug-gnulib
[Top][All Lists]
Advanced

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

Re: [RFE] function to read a file descriptor


From: Ralf Wildenhues
Subject: Re: [RFE] function to read a file descriptor
Date: Wed, 20 Aug 2008 21:29:11 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

* Debarshi Ray wrote on Tue, Aug 19, 2008 at 10:57:33PM CEST:
> > FWIW, your current algorithm of adding BUFSIZ to size causes nonlinear
> > amount of work done in realloc, for reading large files.  You might
> > want to increase memory by a constant factor or BUFSIZ, whichever is
> > larger (e.g., just like read-file does), and thus less often than you
> > recv.
> 
> So the following has been changed to:

> 
>       if (nread < BUFSIZ)
>         break;
>       else
>         *size += (*size / 2 > BUFSIZ) ? *size / 2 : BUFSIZ;

Yes but also you should not reallocate at all if count + BUFSIZ still
fits in the current buffer (i.e., don't realloc for every recv).

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]