Bug 679191: Improve XPT arena allocation behavior when handling allocations larger than the block size. r=njn
authorKyle Huey <khuey@kylehuey.com>
Tue, 16 Aug 2011 07:25:58 -0400
changeset 75365 1248e3a8a8c8a21a4afbcb75634bfc6b1439452f
parent 75364 35657230a209b1d8b709d7da1b2cc1f702332115
child 75366 f8a0d02f12572dfbcdc578990deed6a98d1e8897
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersnjn
bugs679191
milestone8.0a1
Bug 679191: Improve XPT arena allocation behavior when handling allocations larger than the block size. r=njn
xpcom/typelib/xpt/src/xpt_arena.c
--- a/xpcom/typelib/xpt/src/xpt_arena.c
+++ b/xpcom/typelib/xpt/src/xpt_arena.c
@@ -210,18 +210,18 @@ XPT_ArenaMalloc(XPTArena *arena, size_t 
     
     LOG_MALLOC(arena, size, bytes);
 
     if (bytes > arena->space) {
         BLK_HDR* new_block;
         size_t block_header_size = ALIGN_RND(sizeof(BLK_HDR), arena->alignment);
         size_t new_space = arena->block_size;
          
-        if (bytes > new_space - block_header_size)
-            new_space += bytes;
+        while (bytes > new_space - block_header_size)
+            new_space += arena->block_size;
 
         new_block = (BLK_HDR*) calloc(new_space/arena->alignment, 
                                       arena->alignment);
         if (!new_block) {
             arena->next = NULL;
             arena->space = 0;
             return NULL;
         }