commit caa07de623ea23de9bb00c1c15b08036dee8c14b
Author: Jesse Litton <wine@eternaldusk.com>
Date:   Sat Aug 15 09:18:41 2009 -0500

    dbghelp: Don't double memory allocation on every add.
    
    This is a fix for bug 19392.  The add_module and add_memory_block
    functions were doubling their allocations on every call, instead
    of just when the current allocations were exhausted.

diff --git a/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c
index 4108ef4..a2f1633 100644
--- a/dlls/dbghelp/minidump.c
+++ b/dlls/dbghelp/minidump.c
@@ -260,7 +260,7 @@ static BOOL add_module(struct dump_context* dc, const WCHAR* name,
         dc->modules = HeapAlloc(GetProcessHeap(), 0,
                                 dc->alloc_modules * sizeof(*dc->modules));
     }
-    else
+    else if(dc->num_modules >= dc->alloc_modules)
     {
         dc->alloc_modules *= 2;
         dc->modules = HeapReAlloc(GetProcessHeap(), 0, dc->modules,
@@ -394,17 +394,17 @@ static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi)
  */
 static void add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG rva)
 {
-    if (dc->mem)
+    if (!dc->mem)
+    {
+        dc->alloc_mem = 32;
+        dc->mem = HeapAlloc(GetProcessHeap(), 0, dc->alloc_mem * sizeof(*dc->mem));
+    }
+    else if (dc->num_mem >= dc->alloc_mem)
     {
         dc->alloc_mem *= 2;
         dc->mem = HeapReAlloc(GetProcessHeap(), 0, dc->mem,
                               dc->alloc_mem * sizeof(*dc->mem));
     }
-    else
-    {
-        dc->alloc_mem = 32;
-        dc->mem = HeapAlloc(GetProcessHeap(), 0, dc->alloc_mem * sizeof(*dc->mem));
-    }
     if (dc->mem)
     {
         dc->mem[dc->num_mem].base = base;

