home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
c
/
memchr
< prev
next >
Wrap
Text File
|
1994-03-08
|
898b
|
56 lines
#ifdef __STDC__
static char sccs_id[] = "@(#) memchr.c 1.0 " __DATE__ " HJR";
#else
static char sccs_id[] = "@(#) memchr.c 1.0 26/9/90 HJR";
#endif
/* memchr.c (c) Copyright 1990 H.Rogers */
#include <string.h>
#ifdef __STDC__
void *
memchr (register const void *s, register int c, register size_t n)
#else
void *
memchr (s, c, n)
register const void *s;
register int c;
register size_t n;
#endif
{
register unsigned char *_s = (unsigned char *) s;
while (n & 0x07)
{
n--;
if (*_s++ == c)
{
ret:return ((void *) (--_s));
}
}
n >>= 3;
while (n)
{
n--;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
if (*_s++ == c)
goto ret;
}
return (0);
}