Do I need to initiallize(set to 0) memory after calling realloc?

前端 未结 3 1455
不知归路
不知归路 2020-12-19 17:20

I need to implement a simple dynamic array of pointers to a typedef\'ed pointer.
Using realloc each time it\'s requested by the user, the array size will grow by sizeof(

3条回答
  •  旧时难觅i
    2020-12-19 17:43

    Well, it all depends. Do you require that the memory be initialized to 0? If not, then no, you don't need to do anything. Just as is the case with malloc, realloc doesn't perform any initialization. Any memory past the memory that was present in the original block is left uninitialized.

提交回复
热议问题