Why malloc+memset is slower than calloc?

后端 未结 3 1749
迷失自我
迷失自我 2020-11-22 02:17

It\'s known that calloc is different than malloc in that it initializes the memory allocated. With calloc, the memory is set to zero.

3条回答
  •  面向向阳花
    2020-11-22 02:53

    On some platforms in some modes malloc initialises the memory to some typically non-zero value before returning it, so the second version could well initialize the memory twice

提交回复
热议问题