#17 C-Allocators: Mention `realloc` behavior if size is zero
Opened 3 years ago by lsatenstein. Modified 3 years ago

Nothing was stated about what realloc returned when the size is zero.
Is it NULL, or a pointer to NULL?


Nothing was stated about what realloc returned when the size is zero.
Is it NULL, or a pointer to NULL?

Man realloc does not specify return value with size of zero. Is it implementation dependent?

Nothing was stated about what realloc returned when the size is zero.
Is it NULL, or a pointer to NULL?

Man realloc does not specify return value with size of zero. Is it implementation dependent?

Seems so.

The behavior of realloc when the size is 0 is different in C11 (the current version). The standard says (7.20.3.1 for C11, 7.22.3.1 for C1x)

"If the size of the space requested is zero, the behaviour is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object"

Log in to comment on this ticket.

Metadata