[liba] Add strchr to string.h

Change-Id: I6651daa030ad6dc5e567bb78f2f22d48f07524aa
This commit is contained in:
Romain Goyet
2017-07-30 22:13:13 +02:00
committed by Romain Goyet
parent 3ef709502e
commit 159b6f7429
3 changed files with 16 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ objs += $(addprefix liba/src/, \
memmove.o \
memset.o \
strcmp.o \
strchr.o \
strlcpy.o \
strlen.o \
external/sqlite/mem5.o \

View File

@@ -10,9 +10,11 @@ int memcmp(const void * s1, const void * s2, size_t n);
void * memcpy(void * dst, const void * src, size_t n);
void * memmove(void * dst, const void * src, size_t n);
void * memset(void * b, int c, size_t len);
size_t strlen(const char * s);
int strcmp(const char *s1, const char *s2);
char * strchr(const char * s, int c);
int strcmp(const char * s1, const char * s2);
size_t strlcpy(char * dst, const char * src, size_t len);
size_t strlen(const char * s);
LIBA_END_DECLS

11
liba/src/strchr.c Normal file
View File

@@ -0,0 +1,11 @@
#include <string.h>
char * strchr(const char * s, int c) {
while (*s != NULL && *s != c) {
s++;
}
if (*s == c) {
return (char *)s;
}
return NULL;
}