133965Sjdp/*
233965Sjdp
389857Sobrien@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
433965Sjdp
589857SobrienThis function searches memory starting at @code{*@var{s}} for the
689857Sobriencharacter @var{c}.  The search only ends with the first occurrence of
789857Sobrien@var{c}, or after @var{length} characters; in particular, a null
889857Sobriencharacter does not terminate the search.  If the character @var{c} is
989857Sobrienfound within @var{length} characters of @code{*@var{s}}, a pointer
1089857Sobriento the character is returned.  If @var{c} is not found, then @code{NULL} is
1189857Sobrienreturned.
1233965Sjdp
1389857Sobrien@end deftypefn
1433965Sjdp
1533965Sjdp*/
1633965Sjdp
1733965Sjdp#include <ansidecl.h>
1833965Sjdp#include <stddef.h>
1933965Sjdp
2033965SjdpPTR
21218822Sdimmemchr (register const PTR src_void, int c, size_t length)
2233965Sjdp{
2360484Sobrien  const unsigned char *src = (const unsigned char *)src_void;
2433965Sjdp
2589857Sobrien  while (length-- > 0)
2633965Sjdp  {
2733965Sjdp    if (*src == c)
2833965Sjdp     return (PTR)src;
2933965Sjdp    src++;
3033965Sjdp  }
3133965Sjdp  return NULL;
3233965Sjdp}
33