[vox-tech] malloc() is ... old school?

Rod Roark vox-tech@lists.lugod.org
Wed, 19 Mar 2003 18:45:41 -0800


On Wednesday 19 March 2003 06:28 pm, Peter Jay Salzman wrote:
> begin Rod Roark <rod@sunsetsystems.com>
>
> > Stirring up some dust... my 1978 K&R mentions alloc() and
> > calloc() but not malloc().  Then I have this 1985 "Advanced
> > UNIX - A Programmer's Guide" which does talk about malloc().
>
> wow -- my gut reaction was wrong!   okay, so there is some kind of basis
> for that statement.  thanks, rod!
>
> btw, is alloc() == alloca()?

Hm, I don't think so.  K&R says it allocates from "a stack"
but it doesn't look like it means the caller's stack frame.
It also says you must free() in reverse order of the
alloc()s.

Also it doesn't seem to be supported in recent Linux
distributions, which shows one example of why "old school"
is not necessarily safest.

-- Rod