I am doing image processing in C that requires copying large chunks of data around memory - the source and destination never overlap.
What is the absolute fastest way to do this on the x86 platform using GCC (where SSE, SSE2 but NOT SSE3 are available)?
I expect the solution will either be in assembly or using GCC intrinsics?
I found...
Hi guys,
Is there any method to calculate size of a function? I have a pointer to a function and I have to copy entire function using memcpy. I have to malloc some space and know 3rd parameter of memcpy - size. I know that sizeof(function) doesn't work. Do you have any suggestions?
...
Hi,
I've got a following struct
struct teststruct
{
int *a;
void *data;
};
Is it possible to do a deep copy of structure which contains a void pointer? I assume that I cannot tell how many bytes data pointer points to? So I cannot malloc specified number of bytes and do memcpy. Am I right?
...
Well, I'm taking packets straight off the wire and extracting TCP streams from them.
In the short, this means stripping off the various headers (eg, eth->IP->TCP->stream data).
In the function that is called when I've finally gotten through all the headers, I am experiencing a strange error.
/*Meta is a pointer to the IP heade...
hi guys,
i have tried this
char c[4];
int i=89;
memcpy(&c[0],&i,4);
cout<<(int)c[0]<<endl;
cout<<(int)c[1]<<endl;
cout<<(int)c[2]<<endl;
cout<<(int)c[3]<<endl;
the output is like:
89
0
0
0
which pretty trains my stomache cuz i thought the number would be saved in memory like
0x00000059 so how come c[0] is 89 ? i thought it is suppo...
I am trying to send my struct over a UDP socket.
struct Packet {
int seqnum;
char data[BUFFERSIZE];
};
So on the sender I have
bytes = sizeof(packet);
char sending[bytes];
bzero(sending, bytes);
memcpy((void *) sending, (void *) &packet, sizeof(bytes));
bytes = sendto(sockfd, sending, sizeof(sending), 0,
(struct sockaddr *...
I need to copy the content of one buffer to another one in blocks of n bytes (n might vary), several times to check the cache performance.
I use memcpy, but I'm afraid I'm not getting successful results. The block size is variable from some kbytes to Mbytes. And I have to reserve the maximum block to use (long double).
I'm a little los...
Does it violate strict aliasing rules to move items of any type around using uint32_t, then read them back? If so, does it also violate strict aliasing rules to memcpy from an array of uint32_ts to an array of any type, then read the elements back?
The following code sample demonstrates both cases:
#include <assert.h>
#include <stdio....
Is there an "easy" way to implement something like CopyTo() to MemberwiseCopy (instead of Clone() or MemberwiseClone) in C#? I don't want to create a new object, as I want everyone holding the old one to be able to see the attributes of the new one, which may be completely different. While most of these derive from a parent class which c...
I'm doing some maintenance work and ran across something like the following:
std::string s;
s.resize( strLength );
// strLength is a size_t with the length of a C string in it.
memcpy( &s[0], str, strLength );
I know using &s[0] would be safe if it was a std::vector, but is this a safe use of std::string?
...
I've written several copy functions in search of a good memory strategy on PowerPC. Using the Altivec or fp registers with cache hints (dcb*) doubles the performance over a simple byte copy loop for large data. Initially pleased with that, I threw in a regular memcpy to see how it compared... 10x faster than my best! I have no intention ...
so I want to copy a char pointer, asked a friend and he said to use memcpy... so I am trying to do this:
charFilenameAndPath=strtok(filename,".");
memcpy=(charFilename,charFilenameAndPath, sizeof(charFilenameAndPath));
and the compiler is spitting out this:
uTrackSpheres.cpp:176: error: assignment of function ‘void* memcpy(void*, co...
Hello,
I have a pointer to a structure and I need to implement a method that will copy all of the memory contents of a structure. Generally speaking I need to perform a deep copy of a structure.
Here's the structure:
typedef struct {
Size2f spriteSize;
Vertex2f *vertices;
GLubyte *vertex_indices;
} tSprite;
And here's...
Hello
I have this code
char * oldname = new char[strlen(name) + 1];
memcpy(oldname,name,strlen(name) + 1);
name = new char[strlen(oldname) + strlen(r.name) + 1];
memset(name, '\0', strlen(name));
strcat(name,oldname);
strcat(name," ");
strcat(name,r.name);
I understand that it is a no no to use memcpy and memset but I...
I am working with audio data. I'd like to play the sample file in reverse. The data is stored as unsigned ints and packed nice and tight. Is there a way to call memcpy that will copy in reverse order. i.e. if i had 1,2,3,4 stored as ints in an array could i memcpy and magically reverse them so i get 4,3,2,1
...
Hello,
I am porting a project to the iPhone and it uses realloc and memcpy which are not found. What is the header to include?
it's a projet mixing objc and c++ and I am starting to be lost.
Thanks in advance for your help!
...
I am making a simple byte buffer that stores its data in a char array acquired with new and I was just wondering if the memcpy and memmove functions would give me anything weird if used on memory acquired with new or is there anything you would recommend doing instead?
...
I'm designing a real-time system that occasionally has to duplicate a large amount of memory. The memory consists of non-tiny regions, so I expect the copying performance will be fairly close to the maximum bandwidth the relevant components (CPU, RAM, MB) can do. This led me to wonder what kind of raw memory bandwidth modern commodity ma...
Not used memcpy much but here's my code that doesn't work.
memcpy((PVOID)(enginebase+0x74C9D),(void *)0xEB,2);
(enginebase+0x74C9D) is a pointer location to the address of the bytes that I want to patch.
(void *)0xEB is the op code for the kind of jmp that I want.
Only problem is that this crashes the instant that the line tries to ...
I'm using:
ReadProcessMemory(hProcess,(PVOID)(dwEngine_DLL+0x2E15C8+i),&memSnap[i],1,NULL); //Store the memory into a byte array
To store a section of memory into an array of byte, but I realized this was sloppy since I'm in the same address space, but I'm not sure how to do the same thing with memcpy.
...