From a85d3e6e5abd1aa966e773f78ae5fd6257f8cfd6 Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Sun, 8 Jan 2006 01:01:43 -0800 Subject: [PATCH] --- yaml --- r: 16895 b: refs/heads/master c: 30992c97ae9d01b17374fbfab76a869fb4bba500 h: refs/heads/master i: 16893: 45028a48f39002d91f2821aecacc010f5b001bea 16891: f7244aa1935741bd01cb1af63d9d60da03c21e6f 16887: b6e7b6604c8a39b388dbbf7acc0c8db5b259e764 16879: ee325b6728d0e6a3e14c8a5fec545bcca51f6b28 16863: 9ab9b60d63bbe9fd2cb60d7d18a17251ae31c852 16831: 4704438dcf8e105aa44546f1f64f3c631dd12576 16767: cbc6674aadbd3e7458b5977b527d7a01bb8224a9 16639: 2936ac8872b48c45416818f0edd445970e904277 16383: 44c5429a92a99d5f29c59a2bc217206709bccf35 v: v3 --- [refs] | 2 +- trunk/mm/Makefile | 2 +- trunk/mm/slab.c | 37 ------------------------------------- trunk/mm/util.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 trunk/mm/util.c diff --git a/[refs] b/[refs] index d87f648263bb..fb2aea94deb2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 50dd26ba0947aa653f0e42897aad7a4adce4e620 +refs/heads/master: 30992c97ae9d01b17374fbfab76a869fb4bba500 diff --git a/trunk/mm/Makefile b/trunk/mm/Makefile index 2fa6d2ca9f28..74c85ddc9176 100644 --- a/trunk/mm/Makefile +++ b/trunk/mm/Makefile @@ -10,7 +10,7 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \ obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ page_alloc.o page-writeback.o pdflush.o \ readahead.o slab.o swap.o truncate.o vmscan.o \ - prio_tree.o $(mmu-y) + prio_tree.o util.o $(mmu-y) obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o obj-$(CONFIG_HUGETLBFS) += hugetlb.o diff --git a/trunk/mm/slab.c b/trunk/mm/slab.c index 76b092bd0bf7..1c46c6383552 100644 --- a/trunk/mm/slab.c +++ b/trunk/mm/slab.c @@ -3052,20 +3052,6 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp) } EXPORT_SYMBOL(kmem_cache_free); -/** - * kzalloc - allocate memory. The memory is set to zero. - * @size: how many bytes of memory are required. - * @flags: the type of memory to allocate. - */ -void *kzalloc(size_t size, gfp_t flags) -{ - void *ret = kmalloc(size, flags); - if (ret) - memset(ret, 0, size); - return ret; -} -EXPORT_SYMBOL(kzalloc); - /** * kfree - free previously allocated memory * @objp: pointer returned by kmalloc. @@ -3659,26 +3645,3 @@ unsigned int ksize(const void *objp) return obj_reallen(page_get_cache(virt_to_page(objp))); } - - -/* - * 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, gfp_t 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); diff --git a/trunk/mm/util.c b/trunk/mm/util.c new file mode 100644 index 000000000000..5f4bb59da63c --- /dev/null +++ b/trunk/mm/util.c @@ -0,0 +1,39 @@ +#include +#include +#include + +/** + * kzalloc - allocate memory. The memory is set to zero. + * @size: how many bytes of memory are required. + * @flags: the type of memory to allocate. + */ +void *kzalloc(size_t size, gfp_t flags) +{ + void *ret = kmalloc(size, flags); + if (ret) + memset(ret, 0, size); + return ret; +} +EXPORT_SYMBOL(kzalloc); + +/* + * 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, gfp_t 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);