memmove是否将动态内存用于其临时数组 [英] Does memmove use dynamic memory for its temporary array
问题描述
根据 C11 N1570标准草案:
7.24.2.2"memmove
函数":
7.24.2.2 "The memmove
function":
memmove
函数将n
字符从s2
指向的对象复制到s1
指向的对象. 进行复制就像是先将s2
所指向对象中的n
字符首先复制到n
字符的临时数组中,该临时数组不与s1
所指向的对象重叠和s2
,然后将临时数组中的n
字符复制到s1
The
memmove
function copiesn
characters from the object pointed to bys2
into the object pointed to bys1
. Copying takes place as if then
characters from the object pointed to bys2
are first copied into a temporary array ofn
characters that does not overlap the objects pointed to bys1
ands2
, and then then
characters from the temporary array are copied into the object pointed to bys1
因此,如果我选择使用(file_size = 32K)移动大小为32K的缓冲区
So if I choose to move a buffer of size 32K using (file_size = 32K)
memmove(io_Buffer, io_Buffer+17, file_size);
临时缓冲区的大小不是32K吗?
won't the temp buffer be of size 32K?
问题
程序可以自行分配动态内存吗?它会在那一行中分配和释放内存吗?
Can the program allocate dynamic memory on its own? Does it allocate and free the memory in that one line?
推荐答案
我认为您错过了该句子中的好像".这意味着效果将与执行此操作相同,而不是实际上执行该操作.我从未见过真正使用临时数组的memmove
实现.
I think you missed the "as if" in that sentence. That means the effects will be the same as if it did that, not that it will actually do that. I've never seen an implementation of memmove
that actually uses a temporary array.
这篇关于memmove是否将动态内存用于其临时数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!