On Mon, Jun 28, 2004, ?$B0~;3Gn1p?(B wrote:

> 
> On Mon, 28 Jun 2004 07:21:06 +0200 (CEST)
> Richard Levitte - VMS Whacker <[EMAIL PROTECTED]> wrote:
> 
> > In message <[EMAIL PROTECTED]> on Mon, 28 Jun 2004 13:58:35 +0900, Hiroyoshi 
> > Kageyama <[EMAIL PROTECTED]> said:
> > 
> > kageyama.hiroyoshi> BUF_MEM_grow() allocate memory bigger than I
> > kageyama.hiroyoshi> directed length.
> > 
> > Is that a problem?
> 
> No, I have no problem.
> I only wondered at this behavior.
> 

Well the true reason is lost in the mists of SSLeay, however I can see why its
a good idea.

At various points in OpenSSL a single charactar or a small number of
characters are appended to a BUF_MEM structure. BUF_MEM_grow() is called to
check there is enough room and expand it if necessary.

If the buffer was only set to the number of bytes requested such a sequence
would repeatedly resize the buffer with lots of calls to memory allocations
routines and possible performance or fragmentation issues.

This is avoided by allocating more than the requested amount to reduce the
number of expansions.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to