Skip to main content
GameDev.net gamedev.net
🔒 Locked

memcpy vs. CopyMemory

Started by chaosmaster99 Mar 4, 2002 at 12:24 PM 6 replies 17.7k views
Original Post
chaosmaster99
chaosmaster99
In the Microsoft Platform SDK, they recommend using CopyMemory for memory management stuff, but is there any kind of speed difference between it and memcpy? Thanks, Robby "Too late?!" There''s no such thing as "too late!" That''s why they invented death! - Walter Matthau in "Out To Sea"
"Too late?!" There's no such thing as "too late!" That's why they invented death! - Walter Matthau in "Out To Sea"
daerid
daerid
Straight out of WINBASE.H


  
#define CopyMemory RtlCopyMemory


Then, straight out of WINNT.H

  
#define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))


Don''t worry about it.

When you use CopyMemory, you''re using memcpy. There is no difference.
daerid@gmail.com
LessBread
LessBread
This is a good question. At first I thought CopyMemory because memcpy appeared to be an export from crtdll.dll and msvcrt.dll - but after looking at kernel32.dll and ntdll.dll - I found the export for memcpy in ntdll.dll - so I would think memcpy would be faster. The reality probably has to do more with the compiler and where it links the code from.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
daerid
daerid
shazbot

Edited by - daerid on March 4, 2002 4:59:16 PM
daerid@gmail.com
Arild Fines
Arild Fines
daerid - Look at the timestamps on your initial post and Lessbread''s. He didnt read yours before posting.

The computer was conceived as a tool to reduce complexity. Some people found this loss of complexity unacceptable, and developed UNIX to amend the situation.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
poozer
poozer
Don''t you hate the "race conditions" in posting? That''s probably why they let you to delete posts.
LessBread
LessBread
quote:
Original post by Arild Fines
daerid - Look at the timestamps on your initial post and Lessbread''s. He didnt read yours before posting.


Yep. I didn''t see his first post until after I posted. Then I saw his second post with all those CAPITAL LETTERS and I thought he was just a spazz...

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
DrPizza
DrPizza
On x86 they''re the same, and they''re generally generated as intrinsics (i.e. inlined asm) rather than library calls.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.