source: vendor/binutils/current/libiberty/memchr.c

Last change on this file was 609, checked in by bird, 22 years ago

binutils v2.14 - offical sources.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 912 bytes
Line 
1/*
2
3@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
4
5This function searches memory starting at @code{*@var{s}} 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{s}}, a pointer
10to the character is returned. If @var{c} is not found, then @code{NULL} is
11returned.
12
13@end deftypefn
14
15*/
16
17#include <ansidecl.h>
18#ifdef ANSI_PROTOTYPES
19#include <stddef.h>
20#else
21#define size_t unsigned long
22#endif
23
24PTR
25memchr (src_void, c, length)
26 register const PTR src_void;
27 int c;
28 size_t length;
29{
30 const unsigned char *src = (const unsigned char *)src_void;
31
32 while (length-- > 0)
33 {
34 if (*src == c)
35 return (PTR)src;
36 src++;
37 }
38 return NULL;
39}
Note: See TracBrowser for help on using the repository browser.