calloc v/s malloc and time efficiency

前端 未结 7 1239
抹茶落季
抹茶落季 2021-02-04 08:12

I\'ve read with interest the post C difference between malloc and calloc. I\'m using malloc in my code and would like to know what difference I\'ll have using calloc instead.

7条回答
  •  你的背包
    2021-02-04 08:46

    The calloc and memset approaches should be about the same, and maybe slightly faster than zeroing it yourself.

    Regardless, it's all relative to what you do inside your main loop, which could be orders of magnitude larger.

提交回复
热议问题