#include <linux/module.h>
#include "rtl_malloc.c"

rtl_spinlock_t rtl_malloc_lock;

MODULE_PARM (max_size, "i");
MODULE_PARM_DESC (max_size, "Memory pool size in Kb (default=1024)");

MODULE_AUTHOR ("Miguel Masmano Tello <mmasmano@disca.upv.es>");
MODULE_DESCRIPTION ("Dynamic memory manager");

MODULE_LICENSE ("GPL");

static int max_size = 1024;

static volatile void *dummy1 __attribute__ ((unused)) = rt_malloc_ex;
static volatile void *dummy2 __attribute__ ((unused)) = rt_free_ex;

int init_module(void) {
	//void *temp;
	int ret;

	rtl_spin_lock_init(&rtl_malloc_lock);
	ret = init_malloc(max_size); /* with memory_pool_size
					in Kbytes */
	/* We need to import rt_malloc and rt_free from libTLSF. How
	 * to do it in a better way? */
/* 	if (ret == 0) { */
/* 		temp = rt_malloc(1); */
/* 		rt_free(temp); */
/* 	} */

        return ret;
}

void cleanup_module (void) {
         cleanup_malloc();
}

