oleaut32: Grow the marshalling buffer exponentially.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2015-11-26 14:52:03 +08:00 committed by Alexandre Julliard
parent a58c4df5f5
commit 4a315cd78a
1 changed files with 3 additions and 1 deletions

View File

@ -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);