Ai
1 Star 2 Fork 2

e665107/Linux-Device-Drivers-Development

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vmalloc.c 638 Bytes
一键复制 编辑 原始数据 按行查看 历史
swathym14 提交于 2017-10-13 20:40 +08:00 . Code files
#include<linux/init.h>
#include<linux/module.h>
#include <linux/vmalloc.h>
static void *ptr;
static int my_vmalloc_init(void)
{
unsigned long size = 8192;
ptr = vmalloc(size);
if (!ptr) {
/* handle error */
pr_err("memory allocation failed\n");
return -ENOMEM;
} else {
pr_info("Memory allocated successfully\n");
}
return 0;
}
static void my_vmalloc_exit(void)
{
vfree(ptr); //free the allocated memory
pr_info("Memory freed\n");
}
module_init(my_vmalloc_init);
module_exit(my_vmalloc_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("john Madieu <john.madieu@gmail.com>");
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/e665107/Linux-Device-Drivers-Development.git
git@gitee.com:e665107/Linux-Device-Drivers-Development.git
e665107
Linux-Device-Drivers-Development
Linux-Device-Drivers-Development
master

搜索帮助