153 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
4
votes
1
answer
241
views
std::memmove and std::memcpy requiring objects as source, according to cppreference
According to cppreference documentation, std::memmove and std::memcpy would expect an object address as input, which will theoretically limit there usage with buffer obtained from C-like API (mmap, ...
6
votes
1
answer
183
views
is it valid for std::copy_n to do a memmove when a struct has volatile in it?
I have this kind of structure in my code:
struct data
{
volatile int a;
volatile int b;
};
// Some hardware that require specific access
static data *hardware_data = 0x100000;
void function(...
7
votes
2
answers
397
views
Why is rep movsb slow for overlapping forward memmove, and why does libc use it?
TL;DR: memmove that uses rep movsb is magnitudes slow on overlapping array of 8193 bytes compared to memmove for 8191 elements that doesn't use rep movsb.
I'm asking why.
Consider the following ...
1
vote
1
answer
75
views
memmove overwriting objects and their lifetimes
Memmove allows the source and destination to have an overlapping region. And if you're using it with trivially copyable types, the objects copied by memmove will be implicitly created and their ...
6
votes
1
answer
235
views
Is it legal to std::memmove() from one union member to another?
This code is an attempt to reinterpret memory contents as a different type without violating strict aliasing rules. It was suggested as an answer to "Using std::memmove to work around strict ...
1
vote
2
answers
125
views
Is it possible to write on memory that was moved away using memmove in C?
I'm sorry if my code is garbage but I wanted to experiment with string manipulation on an already dynamically allocated string without losing my original pointer so that when I do go ahead and free up ...
1
vote
1
answer
152
views
Using memmove for overlapping strings [duplicate]
I was writing a program where I had to copy two overlapping strings one into another. After looking around, memmove seemed like what I needed for the task. However, it doesn't seem to be working the ...
1
vote
0
answers
383
views
Why does the performance of Golang's memmove (copy/append) vary so much?
I recently encountered a performance problem that I can't easily explain. I hope that someone here can help me understand why these two pieces of code perform so differently.
(Code snippets in this ...
1
vote
2
answers
353
views
Mimicking memmove's behaviour
I am attempting to create a function with a similar work to memmove. I found in the man that the copying is done by including a transitionnal array to where bytes are copied first , which should not ...
2
votes
1
answer
212
views
Are there optimized versions of memmove for when I know the direction?
Imagine that I am implementing inserting and deleting within a small vector. (If this is C++ then assume further that the vector elements are trivially copyable.)
When inserting into the middle of ...
-1
votes
2
answers
117
views
Move element at the end of a space of memory allocated with malloc
I allocated a space of memory with malloc (to have a matrix) and I have to move the "row" at the end, I tried this:
double **dataset = fill_dataset(....);
double* temp = malloc((d + 1) * ...
0
votes
1
answer
218
views
Can memmove accessing the contents of a FILE* and delete information?
Does memmove work on file pointer data?
I am trying to remove a line from a C file. I am trying to use memmove to make this more efficient than the internet's recommendation to create a duplicate file ...
0
votes
1
answer
171
views
How to remove the first string element in array of string
Assuming I have this array of string
char* arr[] = {"Me", "you", "Now", NULL};
My aim is to remove "Me" so that the resultant array is:
arr = {"you", ...
0
votes
1
answer
73
views
Problem of "cyclic data " in x86_64 assembly code
I'm trying to write memmove in assembly:
the problem is that in my section data I've got two line : source and destination, and when I'm trying to pass 20 byte from source to destination while source ...
0
votes
1
answer
232
views
How to allocate memory in the front of data
I am working with sending data to and from a client/server application. I have created my own header scheme. This is the flow I am in question about:
char *data = returnmydata();
int one = 1;
int two =...