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:
parent
a58c4df5f5
commit
4a315cd78a
|
@ -79,12 +79,14 @@ xbuf_resize(marshal_state *buf, DWORD newsize)
|
||||||
|
|
||||||
if(buf->base)
|
if(buf->base)
|
||||||
{
|
{
|
||||||
|
newsize = max(newsize, buf->size * 2);
|
||||||
buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize);
|
buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize);
|
||||||
if(!buf->base)
|
if(!buf->base)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
newsize = max(newsize, 256);
|
||||||
buf->base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newsize);
|
buf->base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newsize);
|
||||||
if(!buf->base)
|
if(!buf->base)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
@ -100,7 +102,7 @@ xbuf_add(marshal_state *buf, const BYTE *stuff, DWORD size)
|
||||||
|
|
||||||
if(buf->size - buf->curoff < 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;
|
if(FAILED(hr)) return hr;
|
||||||
}
|
}
|
||||||
memcpy(buf->base+buf->curoff,stuff,size);
|
memcpy(buf->base+buf->curoff,stuff,size);
|
||||||
|
|
Loading…
Reference in New Issue