X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Fmemchr.c;h=7448ab9e71c3259ad28405720f6acd88ee0801e1;hb=4a422785822ec9302f681c8fbc6ba2cc35231b09;hp=cce300394375b0e28ae1ad40b3f034fdbc1a0b47;hpb=252b5132c753830d5fd56823373aed85f2a0db63;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/memchr.c b/libiberty/memchr.c index cce3003943..7448ab9e71 100644 --- a/libiberty/memchr.c +++ b/libiberty/memchr.c @@ -1,56 +1,29 @@ /* -FUNCTION - <>---find character in memory -INDEX - memchr +@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, @ + size_t @var{n}) -ANSI_SYNOPSIS - #include - void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); +This function searches memory starting at @code{*@var{s}} for the +character @var{c}. The search only ends with the first occurrence of +@var{c}, or after @var{length} characters; in particular, a null +character does not terminate the search. If the character @var{c} is +found within @var{length} characters of @code{*@var{s}}, a pointer +to the character is returned. If @var{c} is not found, then @code{NULL} is +returned. -TRAD_SYNOPSIS - #include - void *memchr(<[src]>, <[c]>, <[length]>) - void *<[src]>; - void *<[c]>; - size_t <[length]>; - -DESCRIPTION - This function searches memory starting at <<*<[src]>>> for the - character <[c]>. The search only ends with the first - occurrence of <[c]>, or after <[length]> characters; in - particular, <> does not terminate the search. - -RETURNS - If the character <[c]> is found within <[length]> characters - of <<*<[src]>>>, a pointer to the character is returned. If - <[c]> is not found, then <> is returned. - -PORTABILITY -<> requires no supporting OS subroutines. - -QUICKREF - memchr ansi pure +@end deftypefn */ #include -#ifdef __STDC__ #include -#else -#define size_t unsigned long -#endif PTR -memchr (src_void, c, length) - register const PTR src_void; - int c; - size_t length; +memchr (register const PTR src_void, int c, size_t length) { const unsigned char *src = (const unsigned char *)src_void; - while (--length >= 0) + while (length-- > 0) { if (*src == c) return (PTR)src;