How detect malloc failure?

后端 未结 5 1519
情歌与酒
情歌与酒 2020-12-03 13:31

What is the portable way to check whether malloc failed to allocate non-zero memory block?

5条回答
  •  鱼传尺愫
    2020-12-03 14:10

    According to the Single Unix Specification, malloc will return NULL and set errno when it fails.

提交回复
热议问题