14fee23f9Smrg /*
24fee23f9Smrg
3*48fb7bfaSmrg @deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, @
4*48fb7bfaSmrg size_t @var{n})
54fee23f9Smrg
64fee23f9Smrg This function searches memory starting at @code{*@var{s}} for the
74fee23f9Smrg character @var{c}. The search only ends with the first occurrence of
84fee23f9Smrg @var{c}, or after @var{length} characters; in particular, a null
94fee23f9Smrg character does not terminate the search. If the character @var{c} is
104fee23f9Smrg found within @var{length} characters of @code{*@var{s}}, a pointer
114fee23f9Smrg to the character is returned. If @var{c} is not found, then @code{NULL} is
124fee23f9Smrg returned.
134fee23f9Smrg
144fee23f9Smrg @end deftypefn
154fee23f9Smrg
164fee23f9Smrg */
174fee23f9Smrg
184fee23f9Smrg #include <ansidecl.h>
194fee23f9Smrg #include <stddef.h>
204fee23f9Smrg
214fee23f9Smrg PTR
memchr(register const PTR src_void,int c,size_t length)224fee23f9Smrg memchr (register const PTR src_void, int c, size_t length)
234fee23f9Smrg {
244fee23f9Smrg const unsigned char *src = (const unsigned char *)src_void;
254fee23f9Smrg
264fee23f9Smrg while (length-- > 0)
274fee23f9Smrg {
284fee23f9Smrg if (*src == c)
294fee23f9Smrg return (PTR)src;
304fee23f9Smrg src++;
314fee23f9Smrg }
324fee23f9Smrg return NULL;
334fee23f9Smrg }
34