LinuxKPI: add strreplace() to string.h

Add strreplace() needed by a driver.
MFC after:	3 days

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32597
This commit is contained in:
Bjoern A. Zeeb 2021-10-22 11:00:36 +00:00
parent b382b78503
commit a5e2a27dca

View File

@ -167,6 +167,19 @@ str_has_prefix(const char *str, const char *prefix)
return (strncmp(str, prefix, len) == 0 ? len : 0);
}
static inline char *
strreplace(char *str, char old, char new)
{
char *p;
p = strchrnul(str, old);
while (p != NULL && *p != '\0') {
*p = new;
p = strchrnul(str, old);
}
return (p);
}
static inline ssize_t
strscpy(char* dst, const char* src, size_t len)
{