diff options
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/string.h')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/string.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 9e1818a38594..f7b64560d254 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -98,6 +98,18 @@ kmemdup(const void *src, size_t len, gfp_t gfp) return (dst); } +/* See slab.h for kvmalloc/kvfree(). */ +static inline void * +kvmemdup(const void *src, size_t len, gfp_t gfp) +{ + void *dst; + + dst = kvmalloc(len, gfp); + if (dst != NULL) + memcpy(dst, src, len); + return (dst); +} + static inline char * strndup_user(const char __user *ustr, long n) { @@ -149,6 +161,24 @@ skip_spaces(const char *str) return (__DECONST(char *, str)); } +/* + * This function trims whitespaces at the end of a string and returns a pointer + * to the first non-whitespace character. + */ +static inline char * +strim(char *str) +{ + char *end; + + end = str + strlen(str); + while (end >= str && (*end == '\0' || isspace(*end))) { + *end = '\0'; + end--; + } + + return (skip_spaces(str)); +} + static inline void * memchr_inv(const void *start, int c, size_t length) { |