Subject: Re: MALLOC()
To: None <itojun@iijlab.net>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: tech-kern
Date: 08/25/2000 22:50:43
> >Don't use MALLOC() for variable-sized allocations.
> 
> 	sorry for stupid question, could you tell me why?

Code space.  Specifically, look at the BUCKETINDX macro in
<sys/malloc.h>, which expands into a binary search for the right size
bucket.

If the size is constant at compile time, BUCKETINDX collapses into a
compile-time constant, and the MALLOC macro compiles into a relatively
short code sequence.  Otherwise, it explodes into a lot of code..

Using malloc() instead when the size allocated is variable makes a lot
more sense.

> 	is there any future plan to change MALLOC() internal?

No.

						- Bill