[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Return Value of realloc(3)
On Sun, Dec 30, 2012 at 1:26 PM, Alan Barrett <apb%cequrux.com@localhost> wrote:
> On Sun, 30 Dec 2012, Abhinav Upadhyay wrote:
>> My point was that we should document this exact behaviour as mentioned
>> in the standards.
>> "If size is 0, either NULL or a unique pointer that can be
>> successfully passed to free(3) is returned."
> I agree. And we might as well also document what happens when zero is
> passed to malloc or calloc.
> If we also document which of the two behaviours is used by NetBSD, then we
> should be careful not to encourage callers to reply on that implementation
> decision, because it may change in the future while remaining compatible
> with relevant standards.
> --apb (Alan Barrett)
Also, what about erealloc(3) in libutil ? Looking at its
implementation, it calls the error handler only when the return
pointer from realloc(3) is NULL. But realloc(3) may not return NULL if
size is 0. I am not sure but probably it is not an error to call
realloc(3) with size as 0?
Main Index |
Thread Index |