FYI - bash crash due to asprintf bug

Robbie Gates robbie@m8s.org
Wed Nov 29 13:44:00 GMT 2006


> reduces asprintf's use of realloc from quadratic
> to log-linear performance (ie. calling realloc every time you add a byte
> is bad, compared to doubling the buffer size every time you call realloc).

Just out of interest, note that a size increase of 50% (i.e. new size
= (3*oldsize)/2) has better properties for certain memory managers, as
opposed to doubling. It has the same asymptotic complexity improvement
as doubling. Roughly speaking, any factor less than the golden ratio
(1+sqrt(5))/2 is good, but 1.5 is (a) cheaply obtanied on most cpu
architectures, and (b) leaves a little space in case the memory
manager adds some overhead. See http://tinyurl.com/yd5669 for details.

 - robbie

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list