delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/14/16:55:17

Date: Mon, 14 Jul 1997 13:53:25 -0700 (PDT)
Message-Id: <199707142053.NAA13035@adit.ap.net>
Mime-Version: 1.0
To: Alan DOT Poppleton AT wanadoo DOT fr
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: mem copies
Cc: djgpp AT delorie DOT com

You wrote:
>I have allocated two memory blocks with the malloc function.  What is
>the fastest method of copying from one to the other?  Would assembler
>help? If so what is the code?  I am currently using memcpy to copy but I
>need to be as fast as possible.

With optimizations turned on, GCC puts memcpy inline, using movsl as much as
possible. I doubt you'll get much faster than that.

>  Also is there are faster method of
>setting a chunk of memory to a certain value than the memset function.

You could theoretically write it in inline assembly, but memset is already
written in assembler, so all you'd save would be some very slight overhead
of the call.

Sorry. TANSTAAFL

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019