Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 8047 invoked from network); 28 Aug 2010 20:13:33 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Aug 2010 20:13:33 -0000 Received: (qmail 91665 invoked by uid 500); 28 Aug 2010 20:13:33 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 91610 invoked by uid 500); 28 Aug 2010 20:13:33 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 91603 invoked by uid 99); 28 Aug 2010 20:13:33 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Aug 2010 20:13:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Aug 2010 20:13:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8EECB2388A38; Sat, 28 Aug 2010 20:11:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r990435 - /apr/apr/trunk/memory/unix/apr_pools.c Date: Sat, 28 Aug 2010 20:11:57 -0000 To: commits@apr.apache.org From: sf@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100828201157.8EECB2388A38@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sf Date: Sat Aug 28 20:11:57 2010 New Revision: 990435 URL: http://svn.apache.org/viewvc?rev=990435&view=rev Log: 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/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=990435&r1=990434&r2=990435&view=diff ============================================================================== --- apr/apr/trunk/memory/unix/apr_pools.c (original) +++ apr/apr/trunk/memory/unix/apr_pools.c Sat Aug 28 20:11:57 2010 @@ -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; }