Skip to content

Commit

Permalink
LibC: Implement strchrnul()
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonbooth authored and awesomekling committed Feb 22, 2020
1 parent ba93131 commit a52b3e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Libraries/LibC/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ char* strchr(const char* str, int c)
}
}

char* strchrnul(const char* str, int c)
{
char ch = c;
for (;; ++str) {
if (*str == ch || !*str)
return const_cast<char*>(str);
}
}

void* memchr(const void* ptr, int c, size_t size)
{
char ch = c;
Expand Down
1 change: 1 addition & 0 deletions Libraries/LibC/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ char* strndup(const char*, size_t);
char* strcpy(char* dest, const char* src);
char* strncpy(char* dest, const char* src, size_t);
char* strchr(const char*, int c);
char* strchrnul(const char*, int c);
char* strstr(const char* haystack, const char* needle);
char* strrchr(const char*, int c);
char* strcat(char* dest, const char* src);
Expand Down

0 comments on commit a52b3e8

Please sign in to comment.