OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / mempcpy.3
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
5 .\" %%%LICENSE_END
6 .\"
7 .\" Heavily based on glibc infopages, copyright Free Software Foundation
8 .\"
9 .\" aeb, 2003, polished a little
10 .TH MEMPCPY 3 2014-03-18 "GNU" "Linux Programmer's Manual"
11 .SH NAME
12 mempcpy, wmempcpy  \- copy memory area
13 .SH SYNOPSIS
14 .nf
15 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
16 .br
17 .B #include <string.h>
18 .sp
19 .BI "void *mempcpy(void *" dest ", const void *" src ", size_t " n );
20 .sp
21 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
22 .br
23 .B #include <wchar.h>
24 .sp
25 .BI "wchar_t *wmempcpy(wchar_t *" dest ", const wchar_t *" src ", size_t " n );
26 .fi
27 .SH DESCRIPTION
28 The
29 .BR mempcpy ()
30 function is nearly identical to the
31 .BR memcpy (3)
32 function.
33 It copies
34 .I n
35 bytes from the object beginning at
36 .I src
37 into the object pointed to by
38 .IR dest .
39 But instead of returning the value of
40 .I dest
41 it returns a pointer to the byte following the last written byte.
42 .PP
43 This function is useful in situations where a number of objects
44 shall be copied to consecutive memory positions.
45 .PP
46 The
47 .BR wmempcpy ()
48 function is identical but takes
49 .I wchar_t
50 type arguments and copies
51 .I n
52 wide characters.
53 .SH RETURN VALUE
54 .I dest
55 +
56 .IR n .
57 .SH VERSIONS
58 .BR mempcpy ()
59 first appeared in glibc in version 2.1.
60 .SH ATTRIBUTES
61 .SS Multithreading (see pthreads(7))
62 The
63 .BR mempcpy ()
64 and
65 .BR wmempcpy ()
66 functions are thread-safe.
67 .SH CONFORMING TO
68 This function is a GNU extension.
69 .SH EXAMPLE
70 .nf
71 void *
72 combine(void *o1, size_t s1, void *o2, size_t s2)
73 {
74     void *result = malloc(s1 + s2);
75     if (result != NULL)
76         mempcpy(mempcpy(result, o1, s1), o2, s2);
77     return result;
78 }
79 .fi
80 .SH SEE ALSO
81 .BR memccpy (3),
82 .BR memcpy (3),
83 .BR memmove (3),
84 .BR wmemcpy (3)
85 .SH COLOPHON
86 This page is part of release 3.68 of the Linux
87 .I man-pages
88 project.
89 A description of the project,
90 information about reporting bugs,
91 and the latest version of this page,
92 can be found at
93 \%http://www.kernel.org/doc/man\-pages/.