gpt4 book ai didi

c - 使用 realloc 调整缓冲区大小

转载 作者:太空狗 更新时间:2023-10-29 15:09:48 25 4
gpt4 key购买 nike

If the area pointed to was moved, a free(ptr) is done.

你能解释一下关于 realloc() 的上面那行代码吗?此行来自 calloc、malloc、realloc 和 free 的手册页。

最佳答案

我认为这更好地解释了它:

If sufficient space does not exist to expand the current block in its current location, a new block of the size for size is allocated, and existing data is copied from the old block to the beginning of the new block. The old block is freed, and the function returns a pointer to the new block.

引用自 realloc in C

关于c - 使用 realloc 调整缓冲区大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/789413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com