What is the portable way to check whether malloc failed to allocate non-zero memory block?
malloc
According to the Single Unix Specification, malloc will return NULL and set errno when it fails.
NULL
errno