- 论坛徽章:
- 0
|
- APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
- apr_size_t in_size)
- {
- apr_uint32_t max_free_index;
- apr_uint32_t size = (APR_UINT32_TRUNC_CAST)in_size;
- #if APR_HAS_THREADS
- apr_thread_mutex_t *mutex;
- mutex = apr_allocator_mutex_get(allocator);
- if (mutex != NULL)
- apr_thread_mutex_lock(mutex);
- #endif /* APR_HAS_THREADS */
- max_free_index = APR_ALIGN(size, BOUNDARY_SIZE) >> BOUNDARY_INDEX;
- allocator->current_free_index += max_free_index;
- allocator->current_free_index -= allocator->max_free_index;
- allocator->max_free_index = max_free_index;
- if (allocator->current_free_index > max_free_index)
- allocator->current_free_index = max_free_index;
- #if APR_HAS_THREADS
- if (mutex != NULL)
- apr_thread_mutex_unlock(mutex);
- #endif
- }
复制代码 看代码看到这个函数的时候不是很明白,请高人指点下
这个函数是设置max_free_index的,这个时候为什么要对current_free_index进行加减操作呢?
current_free_index是指当前内存池中实际存在最大的内存块大小 |
|