c - memmove 是否为其临时数组使用动态内存

标签 c memory

根据 C11 N1570 standard draft :

7.24.2.2 “memmove 函数”:

The memmove function copies n characters from the object pointed to by s2 into the object pointed to by s1. Copying takes place as if the n characters from the object pointed to by s2 are first copied into a temporary array of n characters that does not overlap the objects pointed to by s1 and s2, and then the n characters from the temporary array are copied into the object pointed to by s1

因此,如果我选择使用 (file_size = 32K) 移动大小为 32K 的缓冲区

memmove(io_Buffer, io_Buffer+17, file_size);

临时缓冲区的大小不是 32K 吗?

问题

程序可以自己分配动态内存吗?它会在那一行中分配和释放内存吗?

最佳答案

我想你错过了那句话中的“好像”。这意味着效果将与它那样做一样,而不是它实际上会那样做。我从未见过实际使用临时数组的 memmove 实现。

关于c - memmove 是否为其临时数组使用动态内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55370165/

相关文章:

c++ - 将整数转换为数字数组

powershell - 使用Powershell Windows 2008导出特定进程

c++ - 删除用指针分配的内存(动态数组)

c - _Atomic 类型限定符和类型说明符之间有区别吗?

C - 结构内指针的默认值

c - 从 GSocket 接收垃圾

c# - 将 GUI 组件添加到预编译的应用程序

c - 使用管道复制字符串

c++ - 如何将数组指向嵌入式系统上的某个特定内存地址

python - 连续数组和非连续数组有什么区别?