realloc
    Peter da Silva 
    peter at ficc.uu.net
       
    Tue Apr  4 01:43:12 AEST 1989
    
    
  
  [ malloc(0) -> NULL is a bug]
In article <934 at atanasoff.cs.iastate.edu>, hascall at atanasoff.cs.iastate.edu (John Hascall) writes:
> And what would you have it return?   An Address?
Yes.
> ...which points to zero bytes of allocated storage?
Yes.
> And would successive malloc(0) calls return the same pointer?
No.
> (you're not using any heap with each call)
Yes you are. 4-8 bytes depending on memory model.
> And then consider doing a "free" on such a pointer.
Sure.
malloc(NULL) -> NULL is an optimisation better performed by the programmer.
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Business: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.
Personal: ...!texbell!sugar!peter, peter at sugar.hackercorp.com.
    
    
More information about the Comp.lang.c
mailing list