Allocate and remove memcache.
[cascardo/kernel/samples/04.memcache/.git] / memcache.c
1 #include <linux/module.h>
2 #include <linux/slab.h>
3
4 MODULE_LICENSE("GPL");
5 MODULE_AUTHOR("Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>");
6
7 static struct kmem_cache *memcache;
8
9 static int memcache_init(void)
10 {
11         memcache = kmem_cache_create("memcache", 32, 0, 0, NULL);
12         if (!memcache)
13                 return -ENOMEM;
14         return 0;
15 }
16
17 static void memcache_exit(void)
18 {
19         kmem_cache_destroy(memcache);
20 }
21
22 module_init(memcache_init);
23 module_exit(memcache_exit);