Man page - memcpy(3)

Packages contains this manual

Available languages:

en fr es pl ko ja ru ro de

Manual

MEMCPY

名 前
書 式
説 明
返 り 値
属 性
準 拠
注 意
関 連 項 目
こ の 文 書 に つ い て

名 前

memcpy - メ モ リ ー 領 域 を コ ピ ー す る 。

書 式

#include <string.h>

void *memcpy(void * dest , const void * src , size_t n );

説 明

memcpy () は メ モ リ ー 領 域 src の 先 頭 n バ イ ト を メ モ リ ー 領 域 dest に コ ピ ー す る 。 コ ピ ー 元 の 領 域 と コ ピ ー 先 の 領 域 が 重 な っ て は な ら な い 。 重 な っ て い る 場 合 は memmove (3) を 使 う こ と 。

返 り 値

memcpy () は dest へ の ポ イ ン タ ー を 返 す 。

属 性

こ の 節 で 使 用 さ れ て い る 用 語 の 説 明 に つ い て は 、 attributes (7) を 参 照 。

Image grohtml-37758-1.png

準 拠

POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.

注 意

Failure to observe the requirement that the memory areas do not overlap has been the source of significant bugs. (POSIX and the C standards are explicit that employing memcpy () with overlapping areas produces undefined behavior.) Most notably, in glibc 2.13 a performance optimization of memcpy () on some platforms (including x86-64) included changing the order in which bytes were copied from src to dest .

This change revealed breakages in a number of applications that performed copying with overlapping areas. Under the previous implementation, the order in which the bytes were copied had fortuitously hidden the bug, which was revealed when the copying order was reversed. In glibc 2.14, a versioned symbol was added so that old binaries (i.e., those linked against glibc versions earlier than 2.14) employed a memcpy () implementation that safely handles the overlapping buffers case (by providing an "older" memcpy () implementation that was aliased to memmove (3)).

関 連 項 目

bcopy (3), bstring (3), memccpy (3), memmove (3), mempcpy (3), strcpy (3), strncpy (3), wmemcpy (3)

こ の 文 書 に つ い て

こ の man ペ ー ジ は Linux man-pages プ ロ ジ ェ ク ト の リ リ ー ス 5.10 の 一 部 で あ る 。 プ ロ ジ ェ ク ト の 説 明 と バ グ 報 告 に 関 す る 情 報 は https://www.kernel.org/doc/man-pages/ に 書 か れ て い る 。