On 5/15/15 6:56 PM, Vladimir Panteleev wrote:
On Friday, 15 May 2015 at 17:01:26 UTC, Andrei Alexandrescu wrote:
Since there's a long-established tradition that reallocate() and
free() accept a null pointer,

Question, is there a strong rationale for this? The usefulness is
obvious if malloc(0) returns null, but otherwise, attempting to free a
resource that has never been created usually indicates a bug.

Yah, you don't want to special case null everywhere: cleanup functions, destructors, etc. etc. If deallocation wouldn't accept the null pointer, "if (p) free(p);" would cause carpal tunnel syndrome. -- Andrei

Reply via email to