OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [string/] [memmove.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
FUNCTION
3
        <<memmove>>---move possibly overlapping memory
4
 
5
INDEX
6
        memmove
7
 
8
ANSI_SYNOPSIS
9
        #include <string.h>
10
        void *memmove(void *<[dst]>, const void *<[src]>, size_t <[length]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <string.h>
14
        void *memmove(<[dst]>, <[src]>, <[length]>)
15
        void *<[dst]>;
16
        void *<[src]>;
17
        size_t <[length]>;
18
 
19
DESCRIPTION
20
        This function moves <[length]> characters from the block of
21
        memory starting at <<*<[src]>>> to the memory starting at
22
        <<*<[dst]>>>. <<memmove>> reproduces the characters correctly
23
        at <<*<[dst]>>> even if the two areas overlap.
24
 
25
 
26
RETURNS
27
        The function returns <[dst]> as passed.
28
 
29
PORTABILITY
30
<<memmove>> is ANSI C.
31
 
32
<<memmove>> requires no supporting OS subroutines.
33
 
34
QUICKREF
35
        memmove ansi pure
36
*/
37
 
38
#include <string.h>
39
 
40
/*SUPPRESS 20*/
41
_PTR
42
_DEFUN (memmove, (dst_void, src_void, length),
43
        _PTR dst_void _AND
44
        _CONST _PTR src_void _AND
45
        size_t length)
46
{
47
  char *dst = dst_void;
48
  _CONST char *src = src_void;
49
 
50
  if (src < dst && dst < src + length)
51
    {
52
      /* Have to copy backwards */
53
      src += length;
54
      dst += length;
55
      while (length--)
56
        {
57
          *--dst = *--src;
58
        }
59
    }
60
  else
61
    {
62
      while (length--)
63
        {
64
          *dst++ = *src++;
65
        }
66
    }
67
 
68
  return dst_void;
69
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.