R
Richard Bos
Keith Thompson said:It can't crash if malloc and realloc behave properly. It initially
mallocs 112 bytes, then reallocs more space 128 bytes at a time for
long lines.
But, as we've discussed here before, malloc doesn't behave properly on
all systems. On some systems, malloc can return a non-null result
even if the memory isn't actually available. The memory isn't
actually allocated until you try to write to it. Of course, by then
it's too late to indicate the failure via the result of malloc, so the
system kills your process -- or, perhaps worse, some other process.
True enough, but under those circumstances _any_ code can crash, even
code that doesn't call malloc() at all. I don't think you can get around
that by any amount of ISO C coding, and possibly not using only code at
all unless you have root access to that system. I wouldn't blame that on
ggets.
Richard