Whether malloc() is part of pre-ANSI C
Richard A. O'Keefe
ok at quintus
Tue Oct 4 05:31:38 AEST 1988
Not too long ago, there was a Fortran-vs-C dispute in comp.lang.fortran.
One of the sub-topics was pointers, and at least one of the people arguing
on the Fortran side claimed that malloc() and free() were not part of C,
just part of the UNIX C library.
Now, malloc() and free() _are_ part of the ANSI C draft and have been from
its beginnings. But oddly enough, when I checked The Book, the claim above
turned out to be half true.
"The C Programming Language", Kernighan & Ritchie, 1978, does not list
malloc() in its index, and while free() does appear, the references are
to two different functions. But in Chapter 7 says
Finally, the routines are meant to be "portable", in the sense
that they will exist in compatible form on any system where C
exists, and that programs which confine their system interactions
to facilities provided by the standard library can be moved from
one system to another essentially without change. (p143)
and in the section "Storage Management" (p157) describes
calloc(n, sizeof(object))
cfree(p)
So any system which does not have calloc() or cfree() is, in the words of
The Book, not a "system where C exists", and memory management _has_ been
a required part of C (even if the compiler didn't need to treat these
functions specially).
More information about the Comp.lang.c
mailing list