1mempcpy(3) Library Functions Manual mempcpy(3)
2
3
4
6 mempcpy, wmempcpy - copy memory area
7
9 Standard C library (libc, -lc)
10
12 #define _GNU_SOURCE /* See feature_test_macros(7) */
13 #include <string.h>
14
15 void *mempcpy(void dest[restrict .n], const void src[restrict .n],
16 size_t n);
17
18 #define _GNU_SOURCE /* See feature_test_macros(7) */
19 #include <wchar.h>
20
21 wchar_t *wmempcpy(wchar_t dest[restrict .n],
22 const wchar_t src[restrict .n],
23 size_t n);
24
26 The mempcpy() function is nearly identical to the memcpy(3) function.
27 It copies n bytes from the object beginning at src into the object
28 pointed to by dest. But instead of returning the value of dest it re‐
29 turns a pointer to the byte following the last written byte.
30
31 This function is useful in situations where a number of objects shall
32 be copied to consecutive memory positions.
33
34 The wmempcpy() function is identical but takes wchar_t type arguments
35 and copies n wide characters.
36
38 dest + n.
39
41 For an explanation of the terms used in this section, see at‐
42 tributes(7).
43
44 ┌────────────────────────────────────────────┬───────────────┬─────────┐
45 │Interface │ Attribute │ Value │
46 ├────────────────────────────────────────────┼───────────────┼─────────┤
47 │mempcpy(), wmempcpy() │ Thread safety │ MT-Safe │
48 └────────────────────────────────────────────┴───────────────┴─────────┘
49
51 GNU.
52
54 glibc 2.1.
55
57 void *
58 combine(void *o1, size_t s1, void *o2, size_t s2)
59 {
60 void *result = malloc(s1 + s2);
61 if (result != NULL)
62 mempcpy(mempcpy(result, o1, s1), o2, s2);
63 return result;
64 }
65
67 memccpy(3), memcpy(3), memmove(3), wmemcpy(3)
68
69
70
71Linux man-pages 6.05 2023-07-20 mempcpy(3)