You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2011/03/20 22:48:21 UTC

svn commit: r1083587 - in /apr/apr/branches/1.4.x: ./ memory/unix/apr_pools.c

Author: sf
Date: Sun Mar 20 21:48:20 2011
New Revision: 1083587

URL: http://svn.apache.org/viewvc?rev=1083587&view=rev
Log:
Backport of r990435:

    Fix various off-by-one errors related to current_free_index:
    current_free_index counts pages of size BOUNDARY_SIZE, but every node contains
    index + 1 of such pages

Modified:
    apr/apr/branches/1.4.x/   (props changed)
    apr/apr/branches/1.4.x/memory/unix/apr_pools.c

Propchange: apr/apr/branches/1.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar 20 21:48:20 2011
@@ -1 +1 @@
-/apr/apr/trunk:733052,747990,748361,748371,748565,748888,748902,748988,749810,760443,782838,783398,783958,784633,784773,788588,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,835607,905040,908427,910419,917837-917838,983618,1078845
+/apr/apr/trunk:733052,747990,748361,748371,748565,748888,748902,748988,749810,760443,782838,783398,783958,784633,784773,788588,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,835607,905040,908427,910419,917837-917838,983618,990435,1078845

Modified: apr/apr/branches/1.4.x/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/memory/unix/apr_pools.c?rev=1083587&r1=1083586&r2=1083587&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/memory/unix/apr_pools.c (original)
+++ apr/apr/branches/1.4.x/memory/unix/apr_pools.c Sun Mar 20 21:48:20 2011
@@ -259,7 +259,7 @@ apr_memnode_t *allocator_alloc(apr_alloc
                 allocator->max_index = max_index;
             }
 
-            allocator->current_free_index += node->index;
+            allocator->current_free_index += node->index + 1;
             if (allocator->current_free_index > allocator->max_free_index)
                 allocator->current_free_index = allocator->max_free_index;
 
@@ -299,7 +299,7 @@ apr_memnode_t *allocator_alloc(apr_alloc
         if (node) {
             *ref = node->next;
 
-            allocator->current_free_index += node->index;
+            allocator->current_free_index += node->index + 1;
             if (allocator->current_free_index > allocator->max_free_index)
                 allocator->current_free_index = allocator->max_free_index;
 
@@ -358,7 +358,7 @@ void allocator_free(apr_allocator_t *all
         index = node->index;
 
         if (max_free_index != APR_ALLOCATOR_MAX_FREE_UNLIMITED
-            && index > current_free_index) {
+            && index + 1 > current_free_index) {
             node->next = freelist;
             freelist = node;
         }
@@ -371,8 +371,8 @@ void allocator_free(apr_allocator_t *all
                 max_index = index;
             }
             allocator->free[index] = node;
-            if (current_free_index >= index)
-                current_free_index -= index;
+            if (current_free_index >= index + 1)
+                current_free_index -= index + 1;
             else
                 current_free_index = 0;
         }
@@ -382,8 +382,8 @@ void allocator_free(apr_allocator_t *all
              */
             node->next = allocator->free[0];
             allocator->free[0] = node;
-            if (current_free_index >= index)
-                current_free_index -= index;
+            if (current_free_index >= index + 1)
+                current_free_index -= index + 1;
             else
                 current_free_index = 0;
         }