.\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com)
.\" 2008-07-09, mtk, add rawmemchr()
.\"
-.TH MEMCHR 3 2012-04-16 "" "Linux Programmer's Manual"
+.TH MEMCHR 3 2012-04-23 "" "Linux Programmer's Manual"
.SH NAME
memchr, memrchr, rawmemchr \- scan memory for a character
.SH SYNOPSIS
.SH DESCRIPTION
The
.BR memchr ()
-function scans the first \fIn\fP bytes of the memory
-area pointed to by \fIs\fP for the character \fIc\fP.
-The first byte to
-match \fIc\fP (interpreted as an unsigned character) stops the operation.
+function scans the initial
+.I n
+bytes of the memory
+area pointed to by
+.I s
+for the first instance of
+.IR c .
+Both
+.I c
+and the bytes of the memory area pointed to by
+.I s
+are interpreted as
+.IR "unsigned char" .
.PP
The
.BR memrchr ()
function is like the
.BR memchr ()
function,
-except that it searches backward from the end of the \fIn\fP bytes
-pointed to by \fIs\fP instead of forward from the beginning.
+except that it searches backward from the end of the
+.I n
+bytes pointed to by
+.I s
+instead of forward from the beginning.
The
.BR rawmemchr ()
function is similar to
.BR memchr ():
it assumes (i.e., the programmer knows for certain)
-that the character
+that an instance of
.I c
-lies somewhere in the string
+lies somewhere in the memory area starting at the location pointed to by
.IR s ,
-and so performs an optimized search
-for the character
+and so performs an optimized search for
.IR c
(i.e., no use of a count argument argument to limit the range of the search).
-If the character
+If an instance of
.I c
-is not in the string
-.IR s ,
-then
-.BR rawmemchr ()
-may proceed to search beyond the end of the string,
-and the result is unspecified.
+is not found, the results are unpredictable.
The following call is a fast means of locating a string's
terminating null byte:
.in +4n