realloc
Kenneth Almquist
ka at june.cs.washington.edu
Fri Mar 31 15:53:53 AEST 1989
ark at alice.UUCP (Andrew Koenig) writes (r. e. the ANSI realloc function):
> Of course, not all C implementations behave this way. This
> leaves C programmers in a bind: rely on this behavior or not? If
> not, how does one determine which behavior can be trusted? If
> so, what does one do when one's code breaks on various machines?
Given that the ANSI standard hasn't even been officially released,
C programmers shouldn't rely on this behavior now. Maybe five years
from now we will find that virtually everyone has ANSI conformant C
libraries and we can start taking advantage of the ANSI realloc routine.
Until then, it's less of a hassle to type in a few extra lines of code
rather than having your code break in mysterious ways when it is ported
to a non-ANSI system. The ANSI realloc is different from the majority
of ANSI features, which will cause your program to fail to compile on a
non-ANSI system and can therefore be adopted more aggressively.
As for Andrew's question about what programmer's *can* rely on, the
answer is the current de facto standard, which consists of the
language as defined in the first edition of K&R plus some later
enhancements to the language. Exactly what is included in this
de facto standard is a matter of opinion, which is one reason for
the ANSI standard.
Kenneth Almquist
More information about the Comp.lang.c
mailing list