|
|
Subscribe / Log in / New account

malloc(0)

malloc(0)

Posted Oct 25, 2024 5:48 UTC (Fri) by CChittleborough (subscriber, #60775)
In reply to: malloc(0) by mjw
Parent article: realloc() and the oversize importance of zero-size objects

My reading is that 7.24.4.1 'wins' over 7.24.4.7.

So the official standard says that malloc(0) has Implementation-Defined Behavior, and can return either NULL or a non-null pointer that should never be dereferenced.

Working out which of those is better is the hard part here.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds