X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=mm%2Fslab.c;h=122d031baab2f957bc73abdac853d4195ba78619;hb=21e2c01dc3e38d466eda5871645878d2c3a33261;hp=93cbbbb39f42a783244e6bfaebfbd68f1f017e4c;hpb=4ae7c03943fca73f23bc0cdb938070f41b98101f;p=linux-2.6 diff --git a/mm/slab.c b/mm/slab.c index 93cbbbb39f..122d031baa 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -92,6 +92,7 @@ #include #include #include +#include #include #include @@ -3082,3 +3083,26 @@ unsigned int ksize(const void *objp) return size; } + + +/* + * kstrdup - allocate space for and copy an existing string + * + * @s: the string to duplicate + * @gfp: the GFP mask used in the kmalloc() call when allocating memory + */ +char *kstrdup(const char *s, int gfp) +{ + size_t len; + char *buf; + + if (!s) + return NULL; + + len = strlen(s) + 1; + buf = kmalloc(len, gfp); + if (buf) + memcpy(buf, s, len); + return buf; +} +EXPORT_SYMBOL(kstrdup);