Hi, I'm currently using a for loop to copy an unsigned char array of over 61,000 elements to another array. I was wondering if there was a method or an ASM function I can use to make this faster?
Thanks
Printable View
Hi, I'm currently using a for loop to copy an unsigned char array of over 61,000 elements to another array. I was wondering if there was a method or an ASM function I can use to make this faster?
Thanks
memcpy
use memcpy(). it takes a destination pointer, a source pointer, and the number of bytes you want to copy. you need to include <memory.h> in order to use it. it returns the value of the destination pointer, and it claims that there is "undefined behavior if the source and destination overlap". make sure that the destination is as big as or bigger than the source to avoid buffer overruns.
http://msdn.microsoft.com/library/de...crt_memcpy.asp
Find a better solution to your problem which doesn't involve any copying at all.
> you need to include <memory.h> in order to use it
memcpy() is in string.h - memory.h is a non-standard (probably archaic) header file.
I cant think of any way to not have to copy it. I have two files with hexadecimal data in it and the program loads it into an unsigned char* array at the beginning of the program. Then it goes through a loop of encrypting something, then resets (the data i loaded before gets jumbled in the hexadecimal loop) so i must copy the untouched data over again.
But memcpy() slightly sped it up :)
Before it was doing about 333 cycles per second on the encryption loop now its doing about 350 it seems.