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:
parent
b382b78503
commit
a5e2a27dca
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user