Changeset View
Changeset View
Standalone View
Standalone View
head/sys/compat/linuxkpi/common/include/linux/string.h
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static inline char * | static inline char * | ||||
kstrdup(const char *string, gfp_t gfp) | kstrdup(const char *string, gfp_t gfp) | ||||
{ | { | ||||
char *retval; | char *retval; | ||||
size_t len; | size_t len; | ||||
if (string == NULL) | |||||
return (NULL); | |||||
len = strlen(string) + 1; | len = strlen(string) + 1; | ||||
retval = kmalloc(len, gfp); | retval = kmalloc(len, gfp); | ||||
if (retval != NULL) | if (retval != NULL) | ||||
memcpy(retval, string, len); | memcpy(retval, string, len); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
static inline char * | static inline char * | ||||
kstrndup(const char *string, size_t len, gfp_t gfp) | kstrndup(const char *string, size_t len, gfp_t gfp) | ||||
{ | { | ||||
char *retval; | char *retval; | ||||
if (string == NULL) | |||||
return (NULL); | |||||
retval = kmalloc(len + 1, gfp); | retval = kmalloc(len + 1, gfp); | ||||
if (retval != NULL) | if (retval != NULL) | ||||
strncpy(retval, string, len); | strncpy(retval, string, len); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
static inline const char * | static inline const char * | ||||
kstrdup_const(const char *src, gfp_t gfp) | kstrdup_const(const char *src, gfp_t gfp) | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |