Index: kernel/generic/src/mm/slab.c
===================================================================
--- kernel/generic/src/mm/slab.c	(revision 3c771149415a82b998dbb4c628d9dc0de4459ec6)
+++ kernel/generic/src/mm/slab.c	(revision ce8aed1db35819d4448de2ba811ebb69412a68b8)
@@ -112,4 +112,5 @@
 #include <debug.h>
 #include <bitops.h>
+#include <macros.h>
 
 SPINLOCK_INITIALIZE(slab_cache_lock);
@@ -128,10 +129,21 @@
 static slab_cache_t *slab_extern_cache;
 /** Caches for malloc */
-static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W-SLAB_MIN_MALLOC_W+1];
+static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W - SLAB_MIN_MALLOC_W + 1];
 char *malloc_names[] =  {
-	"malloc-16","malloc-32","malloc-64","malloc-128",
-	"malloc-256","malloc-512","malloc-1K","malloc-2K",
-	"malloc-4K","malloc-8K","malloc-16K","malloc-32K",
-	"malloc-64K","malloc-128K","malloc-256K"
+	"malloc-16",
+	"malloc-32",
+	"malloc-64",
+	"malloc-128",
+	"malloc-256",
+	"malloc-512",
+	"malloc-1K",
+	"malloc-2K",
+	"malloc-4K",
+	"malloc-8K",
+	"malloc-16K",
+	"malloc-32K",
+	"malloc-64K",
+	"malloc-128K",
+	"malloc-256K"
 };
 
@@ -143,5 +155,5 @@
 	count_t available; 	/**< Count of available items in this slab. */
 	index_t nextavail; 	/**< The index of next available item. */
-}slab_t;
+} slab_t;
 
 #ifdef CONFIG_DEBUG
@@ -214,5 +226,5 @@
 static slab_t * obj2slab(void *obj)
 {
-	return (slab_t *)frame_get_parent(ADDR2PFN(KA2PA(obj)), 0);
+	return (slab_t *) frame_get_parent(ADDR2PFN(KA2PA(obj)), 0);
 }
 
@@ -761,5 +773,5 @@
 void slab_free(slab_cache_t *cache, void *obj)
 {
-	_slab_free(cache,obj,NULL);
+	_slab_free(cache, obj, NULL);
 }
 
@@ -879,6 +891,4 @@
 void * malloc(unsigned int size, int flags)
 {
-	int idx;
-
 	ASSERT(_slab_initialized);
 	ASSERT(size && size <= (1 << SLAB_MAX_MALLOC_W));
@@ -887,18 +897,43 @@
 		size = (1 << SLAB_MIN_MALLOC_W);
 
-	idx = fnzb(size-1) - SLAB_MIN_MALLOC_W + 1;
+	int idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
 
 	return slab_alloc(malloc_caches[idx], flags);
 }
 
-void free(void *obj)
-{
-	slab_t *slab;
-
-	if (!obj)
+void * realloc(void *ptr, unsigned int size, int flags)
+{
+	ASSERT(_slab_initialized);
+	ASSERT(size <= (1 << SLAB_MAX_MALLOC_W));
+	
+	void *new_ptr;
+	
+	if (size > 0) {
+		if (size < (1 << SLAB_MIN_MALLOC_W))
+			size = (1 << SLAB_MIN_MALLOC_W);
+		int idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
+		
+		new_ptr = slab_alloc(malloc_caches[idx], flags);
+	} else
+		new_ptr = NULL;
+	
+	if ((new_ptr != NULL) && (ptr != NULL)) {
+		slab_t *slab = obj2slab(ptr);
+		memcpy(new_ptr, ptr, min(size, slab->cache->size));
+	}
+	
+	if (ptr != NULL)
+		free(ptr);
+	
+	return new_ptr;
+}
+
+void free(void *ptr)
+{
+	if (!ptr)
 		return;
 
-	slab = obj2slab(obj);
-	_slab_free(slab->cache, obj, slab);
+	slab_t *slab = obj2slab(ptr);
+	_slab_free(slab->cache, ptr, slab);
 }
 
