免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2208 | 回复: 0
打印 上一主题 下一主题

[C] apr内存池中疑惑 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-05-17 17:15 |只看该作者 |倒序浏览
  1. APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
  2.                                              apr_size_t in_size)
  3. {
  4.     apr_uint32_t max_free_index;
  5.     apr_uint32_t size = (APR_UINT32_TRUNC_CAST)in_size;

  6. #if APR_HAS_THREADS
  7.     apr_thread_mutex_t *mutex;

  8.     mutex = apr_allocator_mutex_get(allocator);
  9.     if (mutex != NULL)
  10.         apr_thread_mutex_lock(mutex);
  11. #endif /* APR_HAS_THREADS */

  12.     max_free_index = APR_ALIGN(size, BOUNDARY_SIZE) >> BOUNDARY_INDEX;
  13.     allocator->current_free_index += max_free_index;
  14.     allocator->current_free_index -= allocator->max_free_index;
  15.     allocator->max_free_index = max_free_index;
  16.     if (allocator->current_free_index > max_free_index)
  17.         allocator->current_free_index = max_free_index;

  18. #if APR_HAS_THREADS
  19.     if (mutex != NULL)
  20.         apr_thread_mutex_unlock(mutex);
  21. #endif
  22. }
复制代码
看代码看到这个函数的时候不是很明白,请高人指点下
这个函数是设置max_free_index的,这个时候为什么要对current_free_index进行加减操作呢?
current_free_index是指当前内存池中实际存在最大的内存块大小
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP