From: Matt Mackall Add mm/util.c for functions common between SLAB and SLOB. Signed-off-by: Matt Mackall Signed-off-by: Andrew Morton --- mm/Makefile | 2 +- mm/slab.c | 37 ------------------------------------- mm/util.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 38 deletions(-) diff -puN mm/Makefile~slob-introduce-mm-utilc-for-shared-functions mm/Makefile --- devel/mm/Makefile~slob-introduce-mm-utilc-for-shared-functions 2005-12-22 05:09:08.000000000 -0800 +++ devel-akpm/mm/Makefile 2005-12-22 05:09:08.000000000 -0800 @@ -10,7 +10,7 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.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 -puN mm/slab.c~slob-introduce-mm-utilc-for-shared-functions mm/slab.c --- devel/mm/slab.c~slob-introduce-mm-utilc-for-shared-functions 2005-12-22 05:09:08.000000000 -0800 +++ devel-akpm/mm/slab.c 2005-12-22 05:09:08.000000000 -0800 @@ -3070,20 +3070,6 @@ void kmem_cache_free(kmem_cache_t * cach 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. * @@ -3676,26 +3662,3 @@ unsigned int ksize(const void *objp) return obj_size(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 -puN /dev/null mm/util.c --- /dev/null 2005-12-20 23:07:20.488229750 -0800 +++ devel-akpm/mm/util.c 2005-12-22 05:09:08.000000000 -0800 @@ -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); _