This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: malloc(0)


> 
> 
> There's been some discussion recently in comp.std.c about what
> malloc(0) and realloc(x, 0) are supposed to do.  The standard allows
> returning some non-null pointer in both cases, which is what we
> currently do.  However, that non-null pointer has peculiar
> characteristics and it seems to me that it would be less surprising if
> both these operations returned NULL.
> 

We used to have it return 0. But we changed it to return 1. I don't
remember what finally convinced us to do so. If the current scheme
is ANSI C compliant, don't change it.


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]