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