OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [libiberty/] [memchr.c] - Blame information for rev 53

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 khays
/*
2
 
3
@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, @
4
  size_t @var{n})
5
 
6
This function searches memory starting at @code{*@var{s}} for the
7
character @var{c}.  The search only ends with the first occurrence of
8
@var{c}, or after @var{length} characters; in particular, a null
9
character does not terminate the search.  If the character @var{c} is
10
found within @var{length} characters of @code{*@var{s}}, a pointer
11
to the character is returned.  If @var{c} is not found, then @code{NULL} is
12
returned.
13
 
14
@end deftypefn
15
 
16
*/
17
 
18
#include <ansidecl.h>
19
#include <stddef.h>
20
 
21
PTR
22
memchr (register const PTR src_void, int c, size_t length)
23
{
24
  const unsigned char *src = (const unsigned char *)src_void;
25
 
26
  while (length-- > 0)
27
  {
28
    if (*src == c)
29
     return (PTR)src;
30
    src++;
31
  }
32
  return NULL;
33
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.