]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/memchr.c
configure.in (MAKEINFO, PERL): Detect these.
[thirdparty/gcc.git] / libiberty / memchr.c
CommitLineData
6599da04 1/*
6599da04 2
aaa5f039 3@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
6599da04 4
aaa5f039
DD
5This function searches memory starting at @code{*}@var{src} for the
6character @var{c}. The search only ends with the first occurrence of
7@var{c}, or after @var{length} characters; in particular, a null
8character does not terminate the search. If the character @var{c} is
9found within @var{length} characters of @code{*}@var{src}, a pointer
10to the character is returned. If @var{c} is not found, then NULL is
11returned.
6599da04 12
aaa5f039 13@end deftypefn
6599da04
JM
14
15*/
16
17#include <ansidecl.h>
18#ifdef __STDC__
19#include <stddef.h>
20#else
21#define size_t unsigned long
22#endif
23
24PTR
25memchr (src_void, c, length)
11a0bb74 26 register const PTR src_void;
6599da04
JM
27 int c;
28 size_t length;
29{
11a0bb74 30 const unsigned char *src = (const unsigned char *)src_void;
6599da04 31
27f66c0b 32 while (length-- > 0)
6599da04
JM
33 {
34 if (*src == c)
35 return (PTR)src;
36 src++;
37 }
38 return NULL;
39}