Debian Codegraph @

upstream/debian-unstable/man3/mempcpy.3

raw
1 '\" t
2 .\" Copyright, Free Software Foundation
3 .\" Copyright 2002, Walter Harms <[email protected]>
4 .\" Copyright, the authors of the Linux man-pages project
5 .\"
6 .\" SPDX-License-Identifier: GPL-1.0-or-later
7 .\"
8 .TH mempcpy 3 2026-02-08 "Linux man-pages 6.18"
9 .SH NAME
10 mempcpy, wmempcpy \- copy memory area
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
17 .B #include <string.h>
18 .P
19 .BR "void *mempcpy(" "size_t n;"
20 .BI " void " dest "[restrict " n "], const void " src "[restrict " n ],
21 .BI " size_t " n );
22 .P
23 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
24 .B #include <wchar.h>
25 .P
26 .BR "wchar_t *wmempcpy(" "size_t n;"
27 .BI " wchar_t " dest "[restrict " n "], const wchar_t " src "[restrict " n ],
28 .BI " size_t " n );
29 .fi
30 .SH DESCRIPTION
31 The
32 .BR mempcpy ()
33 function is nearly identical to the
34 .BR memcpy (3)
35 function.
36 It copies
37 .I n
38 bytes from the object beginning at
39 .I src
40 into the object pointed to by
41 .IR dest .
42 But instead of returning the value of
43 .I dest
44 it returns a pointer to the byte following the last written byte.
45 .P
46 This function is useful in situations where a number of objects
47 shall be copied to consecutive memory positions.
48 .P
49 The
50 .BR wmempcpy ()
51 function is identical but takes
52 .I wchar_t
53 type arguments and copies
54 .I n
55 wide characters.
56 .SH RETURN VALUE
57 .I dest
58 +
59 .IR n .
60 .SH ATTRIBUTES
61 For an explanation of the terms used in this section, see
62 .BR attributes (7).
63 .TS
64 allbox;
65 lbx lb lb
66 l l l.
67 Interface Attribute Value
68 T{
69 .na
70 .nh
71 .BR mempcpy (),
72 .BR wmempcpy ()
73 T} Thread safety MT-Safe
74 .TE
75 .SH STANDARDS
76 GNU.
77 .SH HISTORY
78 glibc 2.1.
79 .SH EXAMPLES
80 .EX
81 void *
82 combine(void *o1, size_t s1, void *o2, size_t s2)
83 {
84 void *result = malloc(s1 + s2);
85 if (result != NULL)
86 mempcpy(mempcpy(result, o1, s1), o2, s2);
87 return result;
88 }
89 .EE
90 .SH SEE ALSO
91 .BR memccpy (3),
92 .BR memcpy (3),
93 .BR memmove (3),
94 .BR wmemcpy (3)