Changeset View
Changeset View
Standalone View
Standalone View
head/sys/libkern/strdup.c
Show All 34 Lines | |||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/libkern.h> | #include <sys/libkern.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
char * | char * | ||||
strdup(const char *string, struct malloc_type *type) | strdup_flags(const char *string, struct malloc_type *type, int flags) | ||||
{ | { | ||||
size_t len; | size_t len; | ||||
char *copy; | char *copy; | ||||
len = strlen(string) + 1; | len = strlen(string) + 1; | ||||
copy = malloc(len, type, M_WAITOK); | copy = malloc(len, type, flags); | ||||
if (copy == NULL) | |||||
return (NULL); | |||||
bcopy(string, copy, len); | bcopy(string, copy, len); | ||||
return (copy); | return (copy); | ||||
} | |||||
char * | |||||
strdup(const char *string, struct malloc_type *type) | |||||
{ | |||||
return (strdup_flags(string, type, M_WAITOK)); | |||||
} | } |