[PATCH] update email address
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / mm / util.c
blob5f4bb59da63c5938a166023f963b985b9ecaf3cb
1 #include <linux/slab.h>
2 #include <linux/string.h>
3 #include <linux/module.h>
5 /**
6 * kzalloc - allocate memory. The memory is set to zero.
7 * @size: how many bytes of memory are required.
8 * @flags: the type of memory to allocate.
9 */
10 void *kzalloc(size_t size, gfp_t flags)
12 void *ret = kmalloc(size, flags);
13 if (ret)
14 memset(ret, 0, size);
15 return ret;
17 EXPORT_SYMBOL(kzalloc);
20 * kstrdup - allocate space for and copy an existing string
22 * @s: the string to duplicate
23 * @gfp: the GFP mask used in the kmalloc() call when allocating memory
25 char *kstrdup(const char *s, gfp_t gfp)
27 size_t len;
28 char *buf;
30 if (!s)
31 return NULL;
33 len = strlen(s) + 1;
34 buf = kmalloc(len, gfp);
35 if (buf)
36 memcpy(buf, s, len);
37 return buf;
39 EXPORT_SYMBOL(kstrdup);