delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/11/17:01:30

From: brunobg AT geocities DOT com (Bruno Barberi Gnecco)
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Copying memory to memory problems
Date: Sat, 11 Jul 1998 20:53:21 GMT
Organization: UNINET (Unisys Brasil Internet Access Service)
Lines: 16
Message-ID: <35a7cf26.7861242@news.unisys.com.br>
NNTP-Posting-Host: saonb02p00.unisys.com.br
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I need to move a part of an array to some bytes ahead. I'd do it using:
   for (i = size; i > x; i--) 
       array[i+1] = array[i];
But this is too slow. How can I do it copying directly from memory to memory? When
I want to move a part of an array back, I'm using:
    memcpy(&numbers[5], &numbers[7], n*sizeof(int));
instead of
   for (i = x; i < size; i++) 
       array[i] = array[i+1];

Is there a backwards memcpy available? If not, what would be the fastest way?
Please note that the number of bytes to move ahead will not be constant...

"There's never enough time to do all the nothing you want" Bill Watterson 
Bruno Barberi Gnecco <brunobg AT geocities DOT com> ICQ #1383173 - PGP 5.0i user 
My other OS is Linux -=O=- Check my homepage at http://graphx.home.ml.org 

- Raw text -


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