使用realloc获得的扩展内存包含哪些内容?

What are the contains of the extended memory obtained using realloc?

当我使用realloc重新调整我之前使用calloc初始化(数组)的内存时,它是否仍然在整个缓冲区中保持为0?或者新的部分没有初始化?

不,不幸的是 realloc 不会初始化分配的 "new" 部分。所以你必须自己做。但是,"old" 部分将保持其值,因此如果您不更改它,您所有的 0 将仍然存在。

考虑到您要增加分配内存的大小,扩展内存区域将具有不确定的值。

引用 C11,章节 §7.22.3.5,(强调我的

[...] The contents of the new object shall be the same as that of the old object prior to deallocation, up to the lesser of the new and old sizes. Any bytes in the new object beyond the size of the old object have indeterminate values.