From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: mem copies Date: Mon, 14 Jul 1997 22:06:06 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 27 Message-ID: <33CAA2CE.6099@cs.com> References: <33C98EA7 DOT 1A09 AT wanadoo DOT fr> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp202.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Alan Poppleton 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. Also is there are faster method of > setting a chunk of memory to a certain value than the memset function. With optimizations on ('-O' switch or its variants '-O1', '-O2', '-O3', etc.), memset() and memcpy() should compile to very efficient code. If you doubt this, try using the '-S' switch to generate assembly code, and read it to see what the compiler produced. The '-m486' option might produce faster code on 486 computers as well. If you're using a Pentium, then you may want to do some assembly coding to get optimal speed, or try downloading PGCC, a version of gcc that incorporates Pentium optimizations. Visit to get the URL - it's right at the top of the page. -- --------------------------------------------------------------------- | John M. Aldrich | "Always listen to experts. They'll | | aka Fighteer I | tell you what can't be done, and why.| | mailto:fighteer AT cs DOT com | Then do it." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------