|
Last change
on this file since 490 was 10, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | FUNCTION
|
|---|
| 3 | <<memchr>>---find character in memory
|
|---|
| 4 |
|
|---|
| 5 | INDEX
|
|---|
| 6 | memchr
|
|---|
| 7 |
|
|---|
| 8 | ANSI_SYNOPSIS
|
|---|
| 9 | #include <string.h>
|
|---|
| 10 | void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
|
|---|
| 11 |
|
|---|
| 12 | TRAD_SYNOPSIS
|
|---|
| 13 | #include <string.h>
|
|---|
| 14 | void *memchr(<[src]>, <[c]>, <[length]>)
|
|---|
| 15 | void *<[src]>;
|
|---|
| 16 | void *<[c]>;
|
|---|
| 17 | size_t <[length]>;
|
|---|
| 18 |
|
|---|
| 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.
|
|---|
| 24 |
|
|---|
| 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.
|
|---|
| 29 |
|
|---|
| 30 | PORTABILITY
|
|---|
| 31 | <<memchr>> requires no supporting OS subroutines.
|
|---|
| 32 |
|
|---|
| 33 | QUICKREF
|
|---|
| 34 | memchr ansi pure
|
|---|
| 35 |
|
|---|
| 36 | */
|
|---|
| 37 |
|
|---|
| 38 | #include <ansidecl.h>
|
|---|
| 39 | #ifdef __STDC__
|
|---|
| 40 | #include <stddef.h>
|
|---|
| 41 | #else
|
|---|
| 42 | #define size_t unsigned long
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | PTR
|
|---|
| 46 | memchr (src_void, c, length)
|
|---|
| 47 | register const PTR src_void;
|
|---|
| 48 | int c;
|
|---|
| 49 | size_t length;
|
|---|
| 50 | {
|
|---|
| 51 | const unsigned char *src = (const unsigned char *)src_void;
|
|---|
| 52 |
|
|---|
| 53 | while (--length >= 0)
|
|---|
| 54 | {
|
|---|
| 55 | if (*src == c)
|
|---|
| 56 | return (PTR)src;
|
|---|
| 57 | src++;
|
|---|
| 58 | }
|
|---|
| 59 | return NULL;
|
|---|
| 60 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.