Thanks. ________________________________ 发件人: Richard Earnshaw <richard.earns...@foss.arm.com> 发送时间: 2020年11月4日 23:45:39 收件人: YaRu Wei(魏亚茹); gcc@gcc.gnu.org 主题: Re: Disassemble the .lib file compiled with gcc-arm-8.3-2019.03-x86_64-arm-eabi compilation tool chain, and found that malloc is optimized to calloc.
On 30/10/2020 08:53, YaRu Wei(魏亚茹) wrote: > Dear gcc: > I find that disassemble the .lib file compiled with > gcc-arm-8.3-2019.03-x86_64-arm-eabi compilation tool chain, and found that > malloc is optimized to calloc. I want to know under what circumstances malloc > will be optimized to calloc? > Thanks > I would presume this would happen if the call to malloc were immediately followed by a call to memset to clear the memory (or an equivalent software coded implementation of memset were detected). Generally, calloc has a better idea of the memory being allocated and can optimize the clearing step if it knows the memory is already zeroed. R.