"Kelly Yancey" <kby...@alcnet.com> writes:
>   I don't know how many programs make use of calloc() but would not a more
> efficient algorithm be to better integrate it with malloc() such that if
> there is a fragment on the heap which can be used, bzero() it and return
> that, otherwise, simply call sbrk() and return that (since it is already
> zero'ed). Currently, in the event that malloc() simply returns newly
> sbrk()'ed memory, we unnecessarily zero it again.

I don't see the point. I've seen very few examples of justified
calloc() use. For instance, I see a lot of people use calloc() instead
of malloc() when allocating strings, just to make sure they'll be
terminated after a strncpy(), instead of simply setting the last
character to '\0' after the strncpy().

When I allocate memory, I usually intend to put something in it.
There's always the odd struct sockaddr_in which I bzero() before
filling it in, but they're usually on the stack.

DES
-- 
Dag-Erling Smorgrav - d...@flood.ping.uio.no


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to