Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30992c97 authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds
Browse files

[PATCH] slob: introduce mm/util.c for shared functions



Add mm/util.c for functions common between SLAB and SLOB.

Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 50dd26ba
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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 \
obj-y			:= bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
			   page_alloc.o page-writeback.o pdflush.o \
			   page_alloc.o page-writeback.o pdflush.o \
			   readahead.o slab.o swap.o truncate.o vmscan.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_SWAP)	+= page_io.o swap_state.o swapfile.o thrash.o
obj-$(CONFIG_HUGETLBFS)	+= hugetlb.o
obj-$(CONFIG_HUGETLBFS)	+= hugetlb.o
+0 −37
Original line number Original line Diff line number Diff line
@@ -3052,20 +3052,6 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp)
}
}
EXPORT_SYMBOL(kmem_cache_free);
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
 * kfree - free previously allocated memory
 * @objp: pointer returned by kmalloc.
 * @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)));
	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);

mm/util.c

0 → 100644
+39 −0
Original line number Original line Diff line number Diff line
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/module.h>

/**
 * 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);