diff options
author | Matt Mackall <mpm@selenic.com> | 2006-01-08 04:01:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-08 23:13:41 -0500 |
commit | 30992c97ae9d01b17374fbfab76a869fb4bba500 (patch) | |
tree | b1ea66bec56fabd80571696d0b081423dcab2340 /mm/slab.c | |
parent | 50dd26ba0947aa653f0e42897aad7a4adce4e620 (diff) |
[PATCH] slob: introduce mm/util.c for shared functions
Add mm/util.c for functions common between SLAB and SLOB.
Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 37 |
1 files changed, 0 insertions, 37 deletions
@@ -3053,20 +3053,6 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp) | |||
3053 | EXPORT_SYMBOL(kmem_cache_free); | 3053 | EXPORT_SYMBOL(kmem_cache_free); |
3054 | 3054 | ||
3055 | /** | 3055 | /** |
3056 | * kzalloc - allocate memory. The memory is set to zero. | ||
3057 | * @size: how many bytes of memory are required. | ||
3058 | * @flags: the type of memory to allocate. | ||
3059 | */ | ||
3060 | void *kzalloc(size_t size, gfp_t flags) | ||
3061 | { | ||
3062 | void *ret = kmalloc(size, flags); | ||
3063 | if (ret) | ||
3064 | memset(ret, 0, size); | ||
3065 | return ret; | ||
3066 | } | ||
3067 | EXPORT_SYMBOL(kzalloc); | ||
3068 | |||
3069 | /** | ||
3070 | * kfree - free previously allocated memory | 3056 | * kfree - free previously allocated memory |
3071 | * @objp: pointer returned by kmalloc. | 3057 | * @objp: pointer returned by kmalloc. |
3072 | * | 3058 | * |
@@ -3659,26 +3645,3 @@ unsigned int ksize(const void *objp) | |||
3659 | 3645 | ||
3660 | return obj_reallen(page_get_cache(virt_to_page(objp))); | 3646 | return obj_reallen(page_get_cache(virt_to_page(objp))); |
3661 | } | 3647 | } |
3662 | |||
3663 | |||
3664 | /* | ||
3665 | * kstrdup - allocate space for and copy an existing string | ||
3666 | * | ||
3667 | * @s: the string to duplicate | ||
3668 | * @gfp: the GFP mask used in the kmalloc() call when allocating memory | ||
3669 | */ | ||
3670 | char *kstrdup(const char *s, gfp_t gfp) | ||
3671 | { | ||
3672 | size_t len; | ||
3673 | char *buf; | ||
3674 | |||
3675 | if (!s) | ||
3676 | return NULL; | ||
3677 | |||
3678 | len = strlen(s) + 1; | ||
3679 | buf = kmalloc(len, gfp); | ||
3680 | if (buf) | ||
3681 | memcpy(buf, s, len); | ||
3682 | return buf; | ||
3683 | } | ||
3684 | EXPORT_SYMBOL(kstrdup); | ||