summaryrefslogtreecommitdiff
path: root/memory/unix
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2010-08-28 20:11:57 +0000
committerStefan Fritsch <sf@apache.org>2010-08-28 20:11:57 +0000
commit8a0467da57025d1b69a35e74f40ba60313ad5f08 (patch)
treebf1bb744fcbfb3205d40c81d8a592d105dd5dda5 /memory/unix
parent685284bd2d862568817c7a895d0c693aa5d42bb5 (diff)
downloadapr-8a0467da57025d1b69a35e74f40ba60313ad5f08.tar.gz
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 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@990435 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory/unix')
-rw-r--r--memory/unix/apr_pools.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index e9be1d438..ca76db33e 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -259,7 +259,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size)
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_allocator_t *allocator, apr_size_t in_size)
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 *allocator, apr_memnode_t *node)
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 *allocator, apr_memnode_t *node)
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 *allocator, apr_memnode_t *node)
*/
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;
}