rts: make `stgMallocBytes` always return non-`NULL`?
Currently stgMallocBytes
will bail out when malloc
fails, reducing the need to check for NULL
on invocation. However, when called with a 0
byte request, it will return NULL
.
I propose to slightly change this, and make malloc
return a non-NULL
pointer even when invoked with 0
, similar to the GNU implementation (where malloc(0)
is turned into malloc(1)
, basically). This is within the spec (malloc(0)
is guaranteed to return either NULL
or a free
'able pointer), and would allow to mark stgMallocBytes
as __attribute__((returns_nonnull))
which allows for some optimizations to kick in.
(Same could apply to stgReallocBytes
and stgCallocBytes
, I guess)