calloc v/s malloc and time efficiency

前端 未结 7 1216
抹茶落季
抹茶落季 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:54

    malloc is faster than Calloc because the reason is that malloc return memory as it is from an operating system. But when you will call Calloc it gets memory from the kernel or operating system and its initializes with its zero and then its return to you. so, the initialization takes time. that's why malloc faster than Calloc

    0 讨论(0)
提交回复
热议问题