tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Return Value of realloc(3)

Hi All,

What should be the expected return value of realloc(3) in case you ask
it to allocate 0 bytes ?

As per the standard
it should either return NULL or a pointer which can be passed to
free(). By running some tests, it appears that on NetBSD it is the
latter case. Is this correct?

If this is the case, then I think it should be clearly documented in
the man page. FWIW on GNU/Linux, it appears that the default bevahiour
is to return NULL in case the requested size is 0 bytes (and it is

The attached patch should do the needful (I hope) :-)
(While there, also fix a typo in malloc.c).


Attachment: malloc.3.diff
Description: Binary data

Attachment: malloc.c.diff
Description: Binary data

Home | Main Index | Thread Index | Old Index