stgMallocBytes: Tolerate malloc(0) returning a NULL ptr
authorHerbert Valerio Riedel <hvr@gnu.org>
Mon, 21 Mar 2016 20:40:23 +0000 (21:40 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Mon, 21 Mar 2016 20:44:13 +0000 (21:44 +0100)
commit1934f7f1066423a6b35b1f17bf63d40c92681d31
treee2adfc3a4232bd7ed64c9ec0bd9c04a9617728b9
parente19e58ced6fb410c8aa79b2193513258c58a38bd
stgMallocBytes: Tolerate malloc(0) returning a NULL ptr

This is valid behaviour for `malloc()` according to ISO C99 and POSIX,
and there's at least one operating system (AIX) which actually does return
NULL for 0-sized allocations.

The `createAdjustor()` routine is currently the only known use-site of
`stgMallocBytes` which may call `stgMallocBytes()` requesting a 0-size
allocation.

Reviewed By: bgamari, austin

Differential Revision: https://phabricator.haskell.org/D2022
rts/RtsUtils.c