File: memchr.c

package info (click to toggle)
xxdiff 1%3A2.5-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,936 kB
  • ctags: 3,420
  • sloc: cpp: 16,125; ansic: 16,104; sh: 1,684; makefile: 295; yacc: 238; lex: 218; python: 216
file content (19 lines) | stat: -rwxr-xr-x 313 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* Support memchr on systems where it doesn't work.  */

#include <config.h>
#include <sys/types.h>

void *
memchr (s, c, n)
     void const *s;
     int c;
     size_t n;
{
  unsigned char const *p = s;
  unsigned char const *lim = p + n;

  for (;  p < lim;  p++)
    if (*p == c)
      return p;
  return 0;
}