mailing list of musl libc
 help / color / mirror / code / Atom feed
559facc0e38fefc6f505cb82a131a8507cd01bcf blob 630 bytes (raw)

 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
 
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "word.h"

/**
 * memchr - Word sized c standard memchr.
 * @s: Source
 * @c: Character
 * @n: Max size of @s
 */
void *memchr(const void *s, int c, size_t n)
{
	const unsigned char *cs = (const unsigned char *)s;
	const size_t *w;

	c = (unsigned char)c;

	for (; (uintptr_t)cs % sizeof(size_t); cs++, n--) {
		if (!n) return NULL;
		if (*cs == c) return (void *)cs;
	}

	for (w = (const size_t *)cs; !word_has_char(*w, c); w++, n--)
		if (!n) return NULL;
	for (cs = (const unsigned char *)w; *cs != c; cs++, n--)
		if (!n) return NULL;

	return (void *)cs;
}
debug log:

solving 559facc ...
found 559facc in https://inbox.vuxu.org/musl/1359936735-31915-3-git-send-email-nwmcsween@gmail.com/
found a0472f7 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 a0472f78e0cfcf16f2f8defbe072a283c6d041a1	src/string/memchr.c

applying [1/1] https://inbox.vuxu.org/musl/1359936735-31915-3-git-send-email-nwmcsween@gmail.com/
diff --git a/src/string/memchr.c b/src/string/memchr.c
index a0472f7..559facc 100644

Checking patch src/string/memchr.c...
Applied patch src/string/memchr.c cleanly.

index at:
100644 559facc0e38fefc6f505cb82a131a8507cd01bcf	src/string/memchr.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).