.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk .\" .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe .\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu) .\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com) .\" 2008-07-09, mtk, add rawmemchr() .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-16, HIROFUMI Nishizuka .\" Updated & Modified 2002-03-24, Yuichi SATO .\" Updated & Modified 2003-11-27, Yuichi SATO .\" Updated 2008-08-11, Akihiro MOTOKI .\" Updated 2012-05-01, Akihiro MOTOKI .\" .TH MEMCHR 3 2015\-01\-10 "" "Linux Programmer's Manual" .SH 名前 memchr, memrchr, rawmemchr \- 文字を探すためにメモリーをスキャンする .SH 書式 .nf \fB#include \fP \fBvoid *memchr(const void *\fP\fIs\fP\fB, int \fP\fIc\fP\fB, size_t \fP\fIn\fP\fB);\fP \fBvoid *memrchr(const void *\fP\fIs\fP\fB, int \fP\fIc\fP\fB, size_t \fP\fIn\fP\fB);\fP \fBvoid *rawmemchr(const void *\fP\fIs\fP\fB, int \fP\fIc\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBmemrchr\fP(): \fBrawmemchr\fP(): _GNU_SOURCE .SH 説明 \fBmemchr\fP() 関数は、ポインター \fIs\fP が指し示すメモリー領域の先頭の \fIn\fP バイトから最初に登場する文字 \fIc\fP を探す。 \fIc\fP と \fIs\fP が指し示すメモリー領域の各バイトは両方とも \fIunsigned char\fP と解釈される。 .PP \fBmemrchr\fP() 関数は \fBmemchr\fP() 関数に似ているが、 先頭から順方向に探すのではなく、 ポインター \fIs\fP が指し示す \fIn\fP バイトのメモリーブロックの 末尾から逆向きに探す。 \fBrawmemchr\fP() 関数は \fBmemchr\fP() と同様だが、 \fIc\fP が \fIs\fP が指す場所 から始まるメモリー領域のどこかにあることを前提にして (つまり、プログラマ はそのことを知っている)、最適化した方法で \fIc\fP の検索を実行する (すなわ ち、検索範囲の上限を示す引き数も使用されない)。\fIc\fP が見つからなかった 場合、その結果はどうなるか分からない。次に示す呼び出しは、文字列終端の ヌルバイトの位置を特定する高速な手段である。 .in +4n .nf char *p = rawmemchr(s,\ \(aq\e0\(aq); .fi .in .SH 返り値 \fBmemchr\fP() 関数と \fBmemrchr\fP() 関数は一致する文字へのポインターを返し、 もし文字が指定メモリー領域に現れない場合は NULL を返す。 \fBrawmemchr\fP() 関数はマッチするバイトが見つかった場合はマッチしたバイトへのポインターを返す。 マッチするバイトが見つからなかった場合、結果は不定である。 .SH バージョン \fBrawmemchr\fP() は glibc バージョン 2.1 で初めて登場した。 \fBmemrchr\fP() は glibc バージョン 2.2 で初めて登場した。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" 関数 \fBmemchr\fP(), \fBmemrchr\fP(), \fBrawmemchr\fP() はスレッドセーフである。 .SH 準拠 \fBmemchr\fP() 関数は SVr4, 4.3BSD, C89, C99, POSIX.1\-2001 に準拠する。 \fBmemrchr\fP() 関数は GNU 拡張であり、glibc 2.1.91 から使用可能である。 \fBrawmemchr\fP() 関数は GNU 拡張であり、glibc 2.1 から使用可能である。 .SH 関連項目 \fBffs\fP(3), \fBindex\fP(3), \fBmemmem\fP(3), \fBrindex\fP(3), \fBstrchr\fP(3), \fBstrpbrk\fP(3), \fBstrrchr\fP(3), \fBstrsep\fP(3), \fBstrspn\fP(3), \fBstrstr\fP(3), \fBwmemchr\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。