Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/string/memcpy.3
Show All 26 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)memcpy.3 8.1 (Berkeley) 6/4/93 | .\" @(#)memcpy.3 8.1 (Berkeley) 6/4/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd June 4, 1993 | .Dd July 14, 2021 | ||||
.Dt MEMCPY 3 | .Dt MEMCPY 3 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm memcpy | .Nm memcpy | ||||
.Nd copy byte string | .Nd copy byte string | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
.Lb libc | .Lb libc | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In string.h | .In string.h | ||||
.Ft void * | .Ft void * | ||||
.Fn memcpy "void *dst" "const void *src" "size_t len" | .Fn memcpy "void *dst" "const void *src" "size_t len" | ||||
.Ft void * | |||||
.Fn mempcpy "void *dst" "const void *src" "size_t len" | |||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Fn memcpy | .Fn memcpy | ||||
function | and | ||||
copies | .Fn mempcpy | ||||
functions | |||||
copy | |||||
.Fa len | .Fa len | ||||
bytes from string | bytes from string | ||||
.Fa src | .Fa src | ||||
to string | to string | ||||
.Fa dst . | .Fa dst . | ||||
If | If | ||||
.Fa src | .Fa src | ||||
and | and | ||||
.Fa dst | .Fa dst | ||||
overlap, the results are not defined. | overlap, the results are not defined. | ||||
.Sh RETURN VALUES | .Sh RETURN VALUES | ||||
The | The | ||||
.Fn memcpy | .Fn memcpy | ||||
function | function | ||||
returns the original value of | returns the original value of | ||||
.Fa dst . | .Fa dst . | ||||
.Pp | |||||
The | |||||
.Fn mempcpy | |||||
function returns a pointer to the byte after the last written byte. | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr bcopy 3 , | .Xr bcopy 3 , | ||||
.Xr memccpy 3 , | .Xr memccpy 3 , | ||||
.Xr memmove 3 , | .Xr memmove 3 , | ||||
.Xr strcpy 3 , | .Xr strcpy 3 , | ||||
.Xr wmemcpy 3 | .Xr wmemcpy 3 | ||||
.Xr wmempcpy 3 | |||||
.Sh STANDARDS | .Sh STANDARDS | ||||
The | The | ||||
.Fn memcpy | .Fn memcpy | ||||
function | function | ||||
conforms to | conforms to | ||||
.St -isoC . | .St -isoC . | ||||
.Sh BUGS | .Sh BUGS | ||||
In this implementation | In this implementation | ||||
.Fn memcpy | .Fn memcpy | ||||
is implemented using | and | ||||
.Fn mempcpy | |||||
are implemented using | |||||
.Xr bcopy 3 , | .Xr bcopy 3 , | ||||
and therefore the strings may overlap. | and therefore the strings may overlap. | ||||
On other systems, copying overlapping strings may produce surprises. | On other systems, copying overlapping strings may produce surprises. | ||||
Programs intended to be portable should use | Programs intended to be portable should use | ||||
.Xr memmove 3 | .Xr memmove 3 | ||||
when | when | ||||
.Fa src | .Fa src | ||||
and | and | ||||
.Fa dst | .Fa dst | ||||
may overlap. | may overlap. |