What should malloc0 do? Return a null pointer or a pointer to 0 bytes?

Q

What should malloc0 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 Portable code must either take care not to call malloc(0), or be prepared for the possibility of a null return.

2015-12-04, 951👍, 0💬