aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slob.c
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-07-17 07:03:21 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:01 -0400
commitef2ad80c7d255ed0449eda947c2d700635b7e0f5 (patch)
treebc44916bdb25de29c8211566a4b5a1c041fa8ab6 /mm/slob.c
parentd45f39cb06610ea456e1d689149b9becacda8b40 (diff)
Slab allocators: consolidate code for krealloc in mm/util.c
The size of a kmalloc object is readily available via ksize(). ksize is provided by all allocators and thus we can implement krealloc in a generic way. Implement krealloc in mm/util.c and drop slab specific implementations of krealloc. Signed-off-by: Christoph Lameter <clameter@sgi.com> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/slob.c')
-rw-r--r--mm/slob.c33
1 files changed, 0 insertions, 33 deletions
diff --git a/mm/slob.c b/mm/slob.c
index b4899079d8b0..154e7bdf3544 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -446,39 +446,6 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
446} 446}
447EXPORT_SYMBOL(__kmalloc_node); 447EXPORT_SYMBOL(__kmalloc_node);
448 448
449/**
450 * krealloc - reallocate memory. The contents will remain unchanged.
451 *
452 * @p: object to reallocate memory for.
453 * @new_size: how many bytes of memory are required.
454 * @flags: the type of memory to allocate.
455 *
456 * The contents of the object pointed to are preserved up to the
457 * lesser of the new and old sizes. If @p is %NULL, krealloc()
458 * behaves exactly like kmalloc(). If @size is 0 and @p is not a
459 * %NULL pointer, the object pointed to is freed.
460 */
461void *krealloc(const void *p, size_t new_size, gfp_t flags)
462{
463 void *ret;
464
465 if (unlikely(!p))
466 return kmalloc_track_caller(new_size, flags);
467
468 if (unlikely(!new_size)) {
469 kfree(p);
470 return NULL;
471 }
472
473 ret = kmalloc_track_caller(new_size, flags);
474 if (ret) {
475 memcpy(ret, p, min(new_size, ksize(p)));
476 kfree(p);
477 }
478 return ret;
479}
480EXPORT_SYMBOL(krealloc);
481
482void kfree(const void *block) 449void kfree(const void *block)
483{ 450{
484 struct slob_page *sp; 451 struct slob_page *sp;