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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [libiberty/] [memchr.c] - Diff between revs 578 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 578 Rev 1765
/*
/*
FUNCTION
FUNCTION
        <<memchr>>---find character in memory
        <<memchr>>---find character in memory
 
 
INDEX
INDEX
        memchr
        memchr
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <string.h>
        #include <string.h>
        void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
        void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <string.h>
        #include <string.h>
        void *memchr(<[src]>, <[c]>, <[length]>)
        void *memchr(<[src]>, <[c]>, <[length]>)
        void *<[src]>;
        void *<[src]>;
        void *<[c]>;
        void *<[c]>;
        size_t <[length]>;
        size_t <[length]>;
 
 
DESCRIPTION
DESCRIPTION
        This function searches memory starting at <<*<[src]>>> for the
        This function searches memory starting at <<*<[src]>>> for the
        character <[c]>.  The search only ends with the first
        character <[c]>.  The search only ends with the first
        occurrence of <[c]>, or after <[length]> characters; in
        occurrence of <[c]>, or after <[length]> characters; in
        particular, <<NULL>> does not terminate the search.
        particular, <<NULL>> does not terminate the search.
 
 
RETURNS
RETURNS
        If the character <[c]> is found within <[length]> characters
        If the character <[c]> is found within <[length]> characters
        of <<*<[src]>>>, a pointer to the character is returned. If
        of <<*<[src]>>>, a pointer to the character is returned. If
        <[c]> is not found, then <<NULL>> is returned.
        <[c]> is not found, then <<NULL>> is returned.
 
 
PORTABILITY
PORTABILITY
<<memchr>>  requires no supporting OS subroutines.
<<memchr>>  requires no supporting OS subroutines.
 
 
QUICKREF
QUICKREF
        memchr ansi pure
        memchr ansi pure
 
 
*/
*/
 
 
#include <ansidecl.h>
#include <ansidecl.h>
#ifdef __STDC__
#ifdef __STDC__
#include <stddef.h>
#include <stddef.h>
#else
#else
#define size_t unsigned long
#define size_t unsigned long
#endif
#endif
 
 
PTR
PTR
memchr (src_void, c, length)
memchr (src_void, c, length)
     register const PTR src_void;
     register const PTR src_void;
     int c;
     int c;
     size_t length;
     size_t length;
{
{
  const unsigned char *src = (const unsigned char *)src_void;
  const unsigned char *src = (const unsigned char *)src_void;
 
 
  while (length-- > 0)
  while (length-- > 0)
  {
  {
    if (*src == c)
    if (*src == c)
     return (PTR)src;
     return (PTR)src;
    src++;
    src++;
  }
  }
  return NULL;
  return NULL;
}
}
 
 

powered by: WebSVN 2.1.0

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