Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
abea1c38
Commit
abea1c38
authored
Apr 28, 2015
by
Daniel Campora
Browse files
lib/libc: Add memchr. We already have strchr, but memchr is useful too.
parent
9fbc265e
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/libc/string0.c
View file @
abea1c38
...
...
@@ -114,6 +114,18 @@ int memcmp(const void *s1, const void *s2, size_t n) {
return
0
;
}
void
*
memchr
(
const
void
*
s
,
int
c
,
size_t
n
)
{
if
(
n
!=
0
)
{
const
unsigned
char
*
p
=
s
;
do
{
if
(
*
p
++
==
c
)
return
((
void
*
)(
p
-
1
));
}
while
(
--
n
!=
0
);
}
return
0
;
}
size_t
strlen
(
const
char
*
str
)
{
int
len
=
0
;
for
(
const
char
*
s
=
str
;
*
s
;
s
++
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment