7 Mar
2014
7 Mar
'14
9:25 a.m.
Matthieu Dorier <[email protected]> writes:
ElectricFence Aborting: Allocating 0 bytes, probably a bug.
I would argue that ElectricFence is wrong here. The standard guarantees that malloc(0) succeeds and it is useful to simplify code and to test for matching free in cases where a positive size is rare. C99 §7.20.3: If the size of the space requested is zero, the behavior 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. Either way, the returned pointer can be passed to free. Are you aware of current malloc implementations which violate the above?