Return a null pointer or a pointer to 0 bytes? .....

Q

What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

✍: Guest

A

The ANSI/ISO Standard says that it may do either; the behavior is implementation-defined ortable code must either take care not to call malloc(0), or be prepared for the possibility of a null return.

2016-04-21, 1745👍, 0💬