apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r761587 - /apr/apr/trunk/memory/unix/apr_pools.c
Date Fri, 03 Apr 2009 09:44:11 GMT
Author: mturk
Date: Fri Apr  3 09:44:11 2009
New Revision: 761587

URL: http://svn.apache.org/viewvc?rev=761587&view=rev
Log:
Use smaller block size and grow exponentially 
Still cannot figure out for wth is final_block used for...

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=761587&r1=761586&r2=761587&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Fri Apr  3 09:44:11 2009
@@ -461,11 +461,12 @@
 #endif /* APR_POOL_DEBUG */
 
 typedef struct block_list_t block_list_t;
-#define BLOCK_LIST_ENTRIES_MAX (512)
+#define BLOCK_LIST_ENTRIES_MIN (13)
 struct block_list_t {
+    int offset;
+    int size;
     block_list_t *next;
-    size_t offset;
-    void *entries[BLOCK_LIST_ENTRIES_MAX];
+    void *entries[BLOCK_LIST_ENTRIES_MIN];
 };
 
 /* The ref field in the apr_pool_t struct holds a
@@ -641,10 +642,12 @@
 
 static void block_list_add_entry(apr_pool_t *pool, void *mem, apr_size_t size)
 {
-    if (pool->blocks->offset == BLOCK_LIST_ENTRIES_MAX) {
-        block_list_t *ml = pool->blocks;
-        pool->blocks = malloc(sizeof(block_list_t));
+    if (pool->blocks->offset == pool->blocks->size) {
+        size_t size = APR_ALIGN((pool->blocks->size << 1), 16);
+        block_list_t *ml = pool->blocks;        
+        pool->blocks = malloc(sizeof(block_list_t) + (sizeof(void *) * size));
         pool->blocks->offset = 0;
+        pool->blocks->size = BLOCK_LIST_ENTRIES_MIN + size;
         pool->blocks->next = ml;
     }
     
@@ -654,7 +657,7 @@
 
 static void block_list_clear(block_list_t *ml)
 {
-    apr_size_t i;
+    int i;
     for (i = 0; i < ml->offset; i++) {
         free(ml->entries[i]);
     }
@@ -672,7 +675,7 @@
 
 static void block_list_destroy(block_list_t *ml)
 {
-    apr_size_t i;
+    int i;
 
     for (i = 0; i < ml->offset; i++) {
         free(ml->entries[i]);
@@ -836,6 +839,7 @@
     pool->blocks = &pool->first_block;
     pool->blocks->offset = 0;
     pool->blocks->next = NULL;
+    pool->blocks->size = BLOCK_LIST_ENTRIES_MIN;
     pool->cleanups = NULL;
     
     



Mime
View raw message