1MEMPCPY(3)                 Linux Programmer's Manual                MEMPCPY(3)
2
3
4

NAME

6       mempcpy, wmempcpy  - copy memory area
7

SYNOPSIS

9       #define _GNU_SOURCE         /* See feature_test_macros(7) */
10       #include <string.h>
11
12       void *mempcpy(void *restrict dest, const void *restrict src, size_t n);
13
14       #define _GNU_SOURCE         /* See feature_test_macros(7) */
15       #include <wchar.h>
16
17       wchar_t *wmempcpy(wchar_t *restrict dest, const wchar_t *restrict src,
18                         size_t n);
19

DESCRIPTION

21       The  mempcpy()  function is nearly identical to the memcpy(3) function.
22       It copies n bytes from the object beginning  at  src  into  the  object
23       pointed  to by dest.  But instead of returning the value of dest it re‐
24       turns a pointer to the byte following the last written byte.
25
26       This function is useful in situations where a number of  objects  shall
27       be copied to consecutive memory positions.
28
29       The  wmempcpy()  function is identical but takes wchar_t type arguments
30       and copies n wide characters.
31

RETURN VALUE

33       dest + n.
34

VERSIONS

36       mempcpy() first appeared in glibc in version 2.1.
37

ATTRIBUTES

39       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
40       tributes(7).
41
42       ┌────────────────────────────────────────────┬───────────────┬─────────┐
43Interface                                   Attribute     Value   
44       ├────────────────────────────────────────────┼───────────────┼─────────┤
45mempcpy(), wmempcpy()                       │ Thread safety │ MT-Safe │
46       └────────────────────────────────────────────┴───────────────┴─────────┘
47

CONFORMING TO

49       This function is a GNU extension.
50

EXAMPLES

52       void *
53       combine(void *o1, size_t s1, void *o2, size_t s2)
54       {
55           void *result = malloc(s1 + s2);
56           if (result != NULL)
57               mempcpy(mempcpy(result, o1, s1), o2, s2);
58           return result;
59       }
60

SEE ALSO

62       memccpy(3), memcpy(3), memmove(3), wmemcpy(3)
63

COLOPHON

65       This  page  is  part of release 5.12 of the Linux man-pages project.  A
66       description of the project, information about reporting bugs,  and  the
67       latest     version     of     this    page,    can    be    found    at
68       https://www.kernel.org/doc/man-pages/.
69
70
71
72GNU                               2021-03-22                        MEMPCPY(3)
Impressum