clean up bcm bases and add primecell peripheral defines
[AROS.git] / compiler / clib / memchr.c
blob63b8bfc7f86d5637b13806840470b4d4bd16c238
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function memchr().
6 */
8 /*****************************************************************************
10 NAME */
11 #include <string.h>
13 void * memchr (
15 /* SYNOPSIS */
16 const void * mem,
17 int c,
18 size_t n)
20 /* FUNCTION
21 Locate the first occurence of c which is converted to an unsigned
22 char in the first n bytes of the memory pointed to by mem.
24 INPUTS
25 mem - pointer to memory that is searched for c
26 c - the character to search for
27 n - how many bytes to search through starting at mem
29 RESULT
30 pointer to the located byte or null if c was not found
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 /* unsigned char to compare chars > 127 */
45 const unsigned char * ptr = (unsigned char *)mem;
47 while (n)
49 if (*ptr == (unsigned char)c)
50 return ((void *)ptr);
52 n --;
53 ptr ++;
56 return NULL;
57 } /* memchr */