diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2017-04-03 11:26:45 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2017-04-03 11:26:45 +0000 |
commit | 671fb04177ab57ab57fda6ffa057766e7c26fe64 (patch) | |
tree | be87050e44a9c51c9b789d8664bc4d50c3c3a76f | |
parent | c2c49c203b0d7e2d3190a9a06dae0ce680c79cf8 (diff) | |
download | libapr-util-671fb04177ab57ab57fda6ffa057766e7c26fe64.tar.gz |
Follow up to r1788334: apr_allocator_align() should take an allocator as
argument, for better scalability of the API.
Update apr_bucket_alloc_aligned_floor() from r1788335 accordingly.
Suggested by ivan.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/branches/1.6.x@1789956 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | buckets/apr_buckets_alloc.c | 8 | ||||
-rw-r--r-- | buckets/apr_buckets_file.c | 2 | ||||
-rw-r--r-- | include/apr_buckets.h | 5 |
3 files changed, 10 insertions, 5 deletions
diff --git a/buckets/apr_buckets_alloc.c b/buckets/apr_buckets_alloc.c index 4401547b..e5838dd0 100644 --- a/buckets/apr_buckets_alloc.c +++ b/buckets/apr_buckets_alloc.c @@ -122,7 +122,8 @@ APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list) #endif } -APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_size_t size) +APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_bucket_alloc_t *list, + apr_size_t size) { if (size <= SMALL_NODE_SIZE) { size = SMALL_NODE_SIZE; @@ -130,10 +131,11 @@ APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_size_t size) else { #if APR_VERSION_AT_LEAST(1,6,0) if (size < APR_MEMNODE_T_SIZE) { - size = apr_allocator_align(0); + size = apr_allocator_align(list->allocator, 0); } else { - size = apr_allocator_align(size - APR_MEMNODE_T_SIZE); + size = apr_allocator_align(list->allocator, + size - APR_MEMNODE_T_SIZE); } #else /* Assumes the minimum (default) allocator's boundary of 4K and diff --git a/buckets/apr_buckets_file.c b/buckets/apr_buckets_file.c index ce927adb..06b7cf00 100644 --- a/buckets/apr_buckets_file.c +++ b/buckets/apr_buckets_file.c @@ -205,7 +205,7 @@ APU_DECLARE(apr_status_t) apr_bucket_file_set_buf_size(apr_bucket *e, a->read_size = APR_BUCKET_BUFF_SIZE; } else { - apr_size_t floor = apr_bucket_alloc_aligned_floor(size); + apr_size_t floor = apr_bucket_alloc_aligned_floor(e->list, size); a->read_size = (size < floor) ? size : floor; } diff --git a/include/apr_buckets.h b/include/apr_buckets.h index 3c27e320..ce64b78d 100644 --- a/include/apr_buckets.h +++ b/include/apr_buckets.h @@ -967,10 +967,13 @@ APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list); * Get the aligned size corresponding to the requested size, but minus the * allocator(s) overhead such that the allocation would remain in the * same boundary. + * @param list The allocator from which to the memory would be allocated. * @param size The requested size. * @return The corresponding aligned/floored size. */ -APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_size_t size); +APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_bucket_alloc_t *list, + apr_size_t size) + __attribute__((nonnull(1))); /** * Allocate memory for use by the buckets. |