diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2009-12-19 05:22:58 +0000 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2009-12-19 05:22:58 +0000 |
commit | c78061061b16307dd33ddc03fc838e404c485ad3 (patch) | |
tree | d68797b0a3aa5ac4bbe3adc8bcbd3b4bb33bd30f /memory/unix | |
parent | 9733acdfba2e88afe78e36c7864777abc6f93ffe (diff) | |
download | apr-c78061061b16307dd33ddc03fc838e404c485ad3.tar.gz |
Please review;
Unless the granularity is 4GB, there appears to be a truncation
issue using 32 bit ints on a 64 bit memory architecture platform.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@892435 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory/unix')
-rw-r--r-- | memory/unix/apr_pools.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 379862ec6..70b939ee0 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -39,8 +39,6 @@ #include <unistd.h> /* for getpid */ #endif -/* XXX Temporary Cast */ -#define APR_UINT32_TRUNC_CAST apr_uint32_t /* * Magic numbers @@ -71,18 +69,18 @@ struct apr_allocator_t { /** largest used index into free[], always < MAX_INDEX */ - apr_uint32_t max_index; + apr_size_t max_index; /** Total size (in BOUNDARY_SIZE multiples) of unused memory before * blocks are given back. @see apr_allocator_max_free_set(). * @note Initialized to APR_ALLOCATOR_MAX_FREE_UNLIMITED, * which means to never give back blocks. */ - apr_uint32_t max_free_index; + apr_size_t max_free_index; /** * Memory size (in BOUNDARY_SIZE multiples) that currently must be freed * before blocks are given back. Range: 0..max_free_index */ - apr_uint32_t current_free_index; + apr_size_t current_free_index; #if APR_HAS_THREADS apr_thread_mutex_t *mutex; #endif /* APR_HAS_THREADS */ @@ -169,7 +167,7 @@ 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; + apr_size_t size = in_size; #if APR_HAS_THREADS apr_thread_mutex_t *mutex; @@ -329,7 +327,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size) return NULL; node->next = NULL; - node->index = (APR_UINT32_TRUNC_CAST)index; + node->index = index; node->first_avail = (char *)node + APR_MEMNODE_T_SIZE; node->endp = (char *)node + size; @@ -680,7 +678,7 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t in_size) free_index = (APR_ALIGN(active->endp - active->first_avail + 1, BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX; - active->free_index = (APR_UINT32_TRUNC_CAST)free_index; + active->free_index = free_index; node = active->next; if (free_index >= node->free_index) return mem; @@ -1055,7 +1053,7 @@ static int psprintf_flush(apr_vformatter_buff_t *vbuff) free_index = (APR_ALIGN(active->endp - active->first_avail + 1, BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX; - active->free_index = (APR_UINT32_TRUNC_CAST)free_index; + active->free_index = free_index; node = active->next; if (free_index < node->free_index) { do { @@ -1156,7 +1154,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) free_index = (APR_ALIGN(active->endp - active->first_avail + 1, BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX; - active->free_index = (APR_UINT32_TRUNC_CAST)free_index; + active->free_index = free_index; node = active->next; if (free_index >= node->free_index) |