File: bcopy.c

package info (click to toggle)
binutils 2.45.50.20251125-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 381,164 kB
  • sloc: ansic: 1,513,144; asm: 826,869; cpp: 216,627; exp: 79,999; makefile: 73,149; sh: 25,556; yacc: 15,067; lisp: 13,640; perl: 13,404; lex: 1,714; ada: 1,681; python: 1,513; pascal: 1,446; cs: 879; java: 478; sed: 191; xml: 95; awk: 25
file content (31 lines) | stat: -rw-r--r-- 694 bytes parent folder | download | duplicates (99)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* bcopy -- copy memory regions of arbitary length

@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})

Copies @var{length} bytes from memory region @var{in} to region
@var{out}.  The use of @code{bcopy} is deprecated in new programs.

@end deftypefn

*/

#include <stddef.h>

void
bcopy (const void *src, void *dest, size_t len)
{
  if (dest < src)
    {
      const char *firsts = (const char *) src;
      char *firstd = (char *) dest;
      while (len--)
	*firstd++ = *firsts++;
    }
  else
    {
      const char *lasts = (const char *)src + (len-1);
      char *lastd = (char *)dest + (len-1);
      while (len--)
        *lastd-- = *lasts--;
    }
}