Import a Cygwin fix for the incorrect use of a pipe capability flag.
[msys.git] / libiberty / memchr.c
blob89aa98f1d94662b9e194ce90177b0e8e9db9a24b
1 /*
2 FUNCTION
3 <<memchr>>---find character in memory
5 INDEX
6 memchr
8 ANSI_SYNOPSIS
9 #include <string.h>
10 void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
12 TRAD_SYNOPSIS
13 #include <string.h>
14 void *memchr(<[src]>, <[c]>, <[length]>)
15 void *<[src]>;
16 void *<[c]>;
17 size_t <[length]>;
19 DESCRIPTION
20 This function searches memory starting at <<*<[src]>>> for the
21 character <[c]>. The search only ends with the first
22 occurrence of <[c]>, or after <[length]> characters; in
23 particular, <<NULL>> does not terminate the search.
25 RETURNS
26 If the character <[c]> is found within <[length]> characters
27 of <<*<[src]>>>, a pointer to the character is returned. If
28 <[c]> is not found, then <<NULL>> is returned.
30 PORTABILITY
31 <<memchr>> requires no supporting OS subroutines.
33 QUICKREF
34 memchr ansi pure
38 #include <ansidecl.h>
39 #ifdef __STDC__
40 #include <stddef.h>
41 #else
42 #define size_t unsigned long
43 #endif
45 PTR
46 memchr (src_void, c, length)
47 register const PTR src_void;
48 int c;
49 size_t length;
51 const unsigned char *src = (const unsigned char *)src_void;
53 while (length-- > 0)
55 if (*src == c)
56 return (PTR)src;
57 src++;
59 return NULL;