apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r892435 - /apr/apr/trunk/memory/unix/apr_pools.c
Date Sat, 19 Dec 2009 05:22:58 GMT
Author: wrowe
Date: Sat Dec 19 05:22:58 2009
New Revision: 892435

URL: http://svn.apache.org/viewvc?rev=892435&view=rev
Log:
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.

Modified:
    apr/apr/trunk/memory/unix/apr_pools.c

Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/memory/unix/apr_pools.c?rev=892435&r1=892434&r2=892435&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Sat Dec 19 05:22:58 2009
@@ -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_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 @@
         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 @@
     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 @@
         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 @@
     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)



Mime
View raw message