summaryrefslogtreecommitdiff
blob: 6d85402f0e754cb00c3ebdaada759211f1f2d3b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
http://linux.bkbits.net:8080/linux-2.6/cset@1.3304.9.72

--- ./include/linux/string.h.ksdp	2006-03-20 11:13:18.000000000 +0300
+++ ./include/linux/string.h	2006-03-20 11:16:11.000000000 +0300
@@ -88,6 +88,8 @@ extern int memcmp(const void *,const voi
 extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 
+extern char *kstrdup(const char *s, int gfp);
+
 #ifdef __cplusplus
 }
 #endif
--- ./mm/slab.c.ksdp	2006-03-20 11:13:43.000000000 +0300
+++ ./mm/slab.c	2006-03-20 11:16:11.000000000 +0300
@@ -2916,6 +2916,28 @@ 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);
+
 void ptrinfo(unsigned long addr)
 {
 	struct page *page;