realloc
John Hascall
hascall at atanasoff.cs.iastate.edu
Sat Apr 1 06:21:27 AEST 1989
In article <9122 at alice.UUCP> andrew at alice.UUCP (Andrew Hume) writes:
>gregg townsend reminds us of the pANS ``feature'' that malloc(0) returns NULL.
>can anyone provide the (or any) justification of this pointless stupid
>definition? i just love the idea that an initialised pointer is SOMETIMES
>indistinguishable from an uninitialised pointer.
And what would you have it return? An Address? ...which points to
zero bytes of allocated storage? And would successive malloc(0)
calls return the same pointer? (you're not using any heap with each
call) And then consider doing a "free" on such a pointer.
Just think of malloc(NULL) as not initialising the pointer,
just as malloc(MORE_BYTES_THAN_WE_GOT) doesn't.
John Hascall
More information about the Comp.lang.c
mailing list