第四节内存管理接口.pptVIP

  • 4
  • 0
  • 约3.46千字
  • 约 19页
  • 2017-09-08 发布于湖北
  • 举报
第四章 内存管理接口 王兴隆 本章内容 malloc函数 calloc函数 free函数 范例4.1 4.1运行结果 mmap函数 munmap函数 范例4.2 #include sys/types.h #include sys/stat.h #include fcntl.h #include unistd.h #include sys/mman.h void main() { // 利用mmap()来读取文件内容 int fd; void *start; struct stat sb; fd = open(“/home/wxlong/OS/memory/test.txt”,O_RDONLY); // 打开文件 fstat(fd,sb); //获取文件大小 start = mmap(NULL,sb.st_size,PROT_READ,MAP_PRIVATE,fd,0); if (start == MAP_FAILED) //判断映射是否成功 return; printf(%s,start); munmap(start,sb.st_size); //解除映射 close(fd); } memset函数 范例4.3 memcpy函数 memmove函数 memcmp函数 memchr函数 评价

文档评论(0)

1亿VIP精品文档

相关文档