From: Dmitry Timoshkov Subject: oleaut32: Grow the marshalling buffer exponentially. Message-Id: <20151126145203.0dd41a59.dmitry@baikal.ru> Date: Thu, 26 Nov 2015 14:52:03 +0800 Most of element sizes that are being added the the marshalling buffer have sizes 4 or 8 bytes, and this patch considerably reduces number of required reallocations. Signed-off-by: Dmitry Timoshkov --- dlls/oleaut32/tmarshal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index f4ce311..4c7fe95 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -79,12 +79,14 @@ xbuf_resize(marshal_state *buf, DWORD newsize) if(buf->base) { + newsize = max(newsize, buf->size * 2); buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize); if(!buf->base) return E_OUTOFMEMORY; } else { + newsize = max(newsize, 256); buf->base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newsize); if(!buf->base) return E_OUTOFMEMORY; @@ -100,7 +102,7 @@ xbuf_add(marshal_state *buf, const BYTE *stuff, DWORD size) if(buf->size - buf->curoff < size) { - hr = xbuf_resize(buf, buf->size + size + 100); + hr = xbuf_resize(buf, buf->size + size); if(FAILED(hr)) return hr; } memcpy(buf->base+buf->curoff,stuff,size); -- 2.6.3