手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux Slab分配器(五)--释放对象

[日期:2012-06-18] 来源:Linux社区  作者:t0nsha [字体:大 中 小]
  1. static void slab_put_obj(struct kmem_cache *cachep, struct slab *slabp,  
  2.                 void *objp, int nodeid)  
  3. {  
  4.     /*得到对象的偏移*/  
  5.     unsigned int objnr = obj_to_index(cachep, slabp, objp);  
  6.   
  7. #if DEBUG   
  8.     /* Verify that the slab belongs to the intended node */  
  9.     WARN_ON(slabp->nodeid != nodeid);  
  10.   
  11.     if (slab_bufctl(slabp)[objnr] + 1 <= SLAB_LIMIT + 1) {  
  12.         printk(KERN_ERR "slab: double free detected in cache "  
  13.                 "'%s', objp %p\n", cachep->name, objp);  
  14.         BUG();  
  15.     }  
  16. #endif   
  17.     /*bufctl数组的相应元素更新为free*/  
  18.     slab_bufctl(slabp)[objnr] = slabp->free;  
  19.     /*free更新为objnr*/  
  20.     slabp->free = objnr;  
  21.     /*非空闲数减1*/  
  22.     slabp->inuse--;  
  23. }  
linux
相关资讯       Linux内存管理 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款