diff options
author | Peter Wemm <peter@FreeBSD.org> | 2018-10-08 08:30:10 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2018-10-08 08:30:10 +0000 |
commit | d29ecdf27f1804b1c533a3739282650ed83dbe31 (patch) | |
tree | 2528d825a15b6f1f2926dd55d258d6d296c787cc /buckets/apr_buckets_alloc.c | |
parent | f5bbf7923e42e842c4c6d067e48b2a94bc40de0d (diff) |
Notes
Diffstat (limited to 'buckets/apr_buckets_alloc.c')
-rw-r--r-- | buckets/apr_buckets_alloc.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/buckets/apr_buckets_alloc.c b/buckets/apr_buckets_alloc.c index 15baa3396655..e5838dd016ec 100644 --- a/buckets/apr_buckets_alloc.c +++ b/buckets/apr_buckets_alloc.c @@ -18,6 +18,7 @@ #include "apr_buckets.h" #include "apr_allocator.h" +#include "apr_version.h" #define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE) @@ -121,6 +122,37 @@ 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_bucket_alloc_t *list, + apr_size_t size) +{ + if (size <= SMALL_NODE_SIZE) { + size = SMALL_NODE_SIZE; + } + else { +#if APR_VERSION_AT_LEAST(1,6,0) + if (size < APR_MEMNODE_T_SIZE) { + size = apr_allocator_align(list->allocator, 0); + } + else { + size = apr_allocator_align(list->allocator, + size - APR_MEMNODE_T_SIZE); + } +#else + /* Assumes the minimum (default) allocator's boundary of 4K and + * minimum (immutable before APR-1.6.x) allocation size of 8K, + * hence possibly (yet unlikely) under-estimating the floor... + */ + size = APR_ALIGN(size, 4096); + if (size < 8192) { + size = 8192; + } +#endif + size -= APR_MEMNODE_T_SIZE; + } + size -= SIZEOF_NODE_HEADER_T; + return size; +} + APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list) { |