blob: 75c44b962c04b40d13369a6e875ee7617e85fac6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
#include <xen/string.h>
/**
* memchr - Find a character in an area of memory.
* @s: The memory area
* @c: The byte to search for
* @n: The size of the area.
*
* returns the address of the first occurrence of @c, or %NULL
* if @c is not found
*/
void *(memchr)(const void *s, int c, size_t n)
{
const unsigned char *p = s;
while (n--)
if ((unsigned char)c == *p++)
return (void *)(p - 1);
return NULL;
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*/
|