memmove() is a C standard library function to copy a block of memory. It work even if the source and the destination overlap.
Questions tagged [memmove]
144 questions
6
votes
1 answer
Why memmove() function works this way?
I was going through various questions related to memmove() vs memcpy() on Stack Overflow.
There was this post that implied that if the source address (data to be copied from) is greater than destination address (data to be copied to), it will…

Yatendra Rathore
- 333
- 2
- 13
5
votes
2 answers
Why does `memmove` use `void *` as parameter instead of `char *`?
The definition of the c library function memmove is like the following:
void* memmove(void *s1, const void *s2, size_t n)
{
char *sc1;
const char *sc2;
sc1 = s1;
sc2 = s2;
...
}
I'm wondering why do we need to use void* and…

Fihop
- 3,127
- 9
- 42
- 65
5
votes
3 answers
How to define C-Enumeration types in python
I have an enumeration data type in C. How should I declare that in python-ctypes? I want this enum variable to be part of a structure and the assignment of the values to this structure would be done through memmove. After assigning, I want to…

Raj Kumar
- 143
- 2
- 11
5
votes
2 answers
Regarding implementation of memmove
I was looking at public-domain implementations on wikibooks.org. It implements memmove() as following explicitly stating that it is "not completely portable"! I was wondering as to why:
parenthesis were placed on the first line of the code,…

Quiescent
- 1,088
- 7
- 18
5
votes
5 answers
Will memcpy or memmove cause problems copying classes?
Suppose I have any kind of class or structure. No virtual functions or anything, just some custom constructors, as well as a few pointers that would require cleanup in the destructor.
Would there be any adverse affects to using memcpy or memmove on…

Serge
- 1,974
- 6
- 21
- 33
4
votes
3 answers
What's the difference between memmove and bcopy?
I understand the difference between memcpy and memmove: memmove handles the overlapping of src and dst. I checked the man page for bcopy and it seems to also handle overlapping. So I'm wondering if there is any difference between memmove and bcopy?

Tsak
- 133
- 7
4
votes
1 answer
Circular shifting an array with `memmove`
Say I have an integer array like such
#define MAX 5
int bar [MAX] = {0};
int foo [MAX] = {3,1,0,0,0};
Now I'd like to shift this array so that all null entries are to the left, i.e. bar = {0,0,0,3,1}.
I thought I could do this by
Finding the…

Bernardo Meurer
- 2,295
- 5
- 31
- 52
4
votes
1 answer
Are the restrictions of std::copy more relaxed than std::memcopy?
With regard to the issues copy vs. memcpy vs memmove(excellent info here, btw.), I have been reading up and it would seem to me, that unlike what is colloquially said, for example at cppreferenceNote: memcpy has been changed to memmove since taking…

Martin Ba
- 37,187
- 33
- 183
- 337
4
votes
2 answers
Cleaner way to remove a substring from str in C
I have the following string ID is a sample string remove to /0.10, I would like to end up with the following: ID/0.10.
This is what I came up with. However, I'm looking for a cleaner/nicer way of doing this.
#include
#include…

Kayla
- 899
- 2
- 6
- 16
3
votes
2 answers
Error when dealing with memory - mremap_chunk: Assertion
It seems like my previous post but issue here is different ..
This is the C structure for problem -
typedef struct ip_esp_private { /* keep track of things privately */
u_int32_t type;
u_int32_t ivlen;
u_int32_t icvlen; …

Udit Gupta
- 3,162
- 11
- 43
- 71
3
votes
1 answer
Is there a standard library equivalent of memmove?
The standard library offers std::copy, which can be seen as a generalization/generification of C's memcpy(). It also maintains the requirement of memcpy(), for the range [first, last) to be disjoint from the range [d_first , d_first +…

einpoklum
- 118,144
- 57
- 340
- 684
3
votes
1 answer
How to save a string temporary variable in assembly x86-64
Im new to assembly and I've to write the memmove function in assembly x86-64, and it said :
The memmove() function copies n bytes from memory area src to memory area dest. The memory areas may overlap: copying takes place as though the bytes in src…

MacBess
- 61
- 4
3
votes
2 answers
Free a part of malloc
Is there any way to free some part of memory you created by using malloc();
Suppose I have this:
int *temp;
temp = ( int *) malloc ( 10 * sizeof(int));
free(temp);
free will release all 20 byte of memory but suppose I only need 10 bytes. Can I…

Štístko
- 180
- 7
3
votes
2 answers
Does memmove actually "move" a chunk of memory and leave behind zeros at the source?
Possible Duplicate:
memcpy vs memmove
Does memmove actually "move" a chunk of memory? If so, does it leave the memory with zeros? Or, is it just like memcpy? I am looking at the man page, and I do not believe my assumption is correct. If I want…

hut123
- 445
- 3
- 7
- 14
3
votes
6 answers
Do strncpy/memcpy/memmove copy the data byte by byte or in another efficiently way?
As we know, in a multi-bytes word computer such as x86/x86_64, it is more efficiently to copy/move a big bulk of memory word by word (4 or 8 bytes per step), than to do so byte by byte.
I'm curious about which way would strncpy/memcpy/memmove do…

Leon
- 1,489
- 1
- 12
- 31