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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.18.50/] [libiberty/] [memchr.c] - Blame information for rev 438

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

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

powered by: WebSVN 2.1.0

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