linuxkpi: Add str_has_prefix

This function test if the string str begins with the string pointed
at by prefix.

Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23767
This commit is contained in:
Emmanuel Vadot 2020-02-20 17:20:50 +00:00
parent 8f0c734385
commit 1a7ba9a01c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358177

View File

@ -154,4 +154,13 @@ memchr_inv(const void *start, int c, size_t length)
return (NULL);
}
static inline size_t
str_has_prefix(const char *str, const char *prefix)
{
size_t len;
len = strlen(prefix);
return (strncmp(str, prefix, len) == 0 ? len : 0);
}
#endif /* _LINUX_STRING_H_ */