Sheng Peng recently discovered that
callocMustSucceed(0, x)
(a request for zero amount of memory)
succeeds on linux but fails on RTEMS.
(This is because according to the ISO C and IEEE 1003.1 standard
the allocator may either return NULL [rtems] or a unique
pointer that is acceptable to free() [linux] in the case
of a zero 'size' argument)
IMO, the EPICS implementation needs to be fixed to
give consistent behavior and the API should define
whether it is legal to request zero memory (with
the side-effect of callocMustSucceed() returning
a bogus or NULL pointer which probably is against
its purpose) or not (with the possible side-effect
of breaking code).
My suggestion would be replacing the
if (mem==0)
tests by
if (mem==0 && size != 0)
thus legalizing mallocMustSucceed(0) on all platforms.
-- Till