diff options
author | David Howells <dhowells@redhat.com> | 2017-07-04 18:25:02 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-07-06 09:27:09 +0200 |
commit | f35157417215ec138c920320c746fdb3e04ef1d5 (patch) | |
tree | 5d8e536fc716419fe3b9474dcacb92c6f055930f /include | |
parent | Linux 4.12-rc7 (diff) | |
download | linux-f35157417215ec138c920320c746fdb3e04ef1d5.tar.xz linux-f35157417215ec138c920320c746fdb3e04ef1d5.zip |
Provide a function to create a NUL-terminated string from unterminated data
Provide a function, kmemdup_nul(), that will create a NUL-terminated string
from an unterminated character array where the length is known in advance.
This is better than kstrndup() in situations where we already know the
string length as the strnlen() in kstrndup() is superfluous.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/string.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/string.h b/include/linux/string.h index 537918f8a98e..3dd944cfe171 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -131,6 +131,7 @@ extern char *kstrdup(const char *s, gfp_t gfp) __malloc; extern const char *kstrdup_const(const char *s, gfp_t gfp); extern char *kstrndup(const char *s, size_t len, gfp_t gfp); extern void *kmemdup(const void *src, size_t len, gfp_t gfp); +extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp); extern char **argv_split(gfp_t gfp, const char *str, int *argcp); extern void argv_free(char **argv); |